Windows PowerShell is a powerful tool that can be used to manage and automate tasks on Windows systems. One of the most useful commands in PowerShell is the New-NetIPAddress command, which allows users to configure IP addresses on their network. In this article, we’ll take a look at how to use the New-NetIPAddress command, including its syntax, parameters, inputs, outputs, examples, and tips.

What is the New-NetIPAddress Command?

The New-NetIPAddress command is a Windows PowerShell command that allows users to configure IP addresses on their network. It can be used to create, modify, or delete IP addresses, as well as to configure IP address settings. This command is especially useful for configuring static IP addresses, which are necessary for certain types of network connections.

Syntax of the New-NetIPAddress Command

The syntax of the New-NetIPAddress command is as follows:

New-NetIPAddress [-InterfaceIndex] <UInt32> [-IPAddress] <String> [-PrefixLength] <UInt32> [-DefaultGateway] <String> [-AddressFamily] <AddressFamily> [-Type] <IPAddressType> [-PrefixOrigin] <PrefixOrigin> [-SuffixOrigin] <SuffixOrigin> [-SkipAsSource] <Boolean> [-PolicyStore] <String> [-PassThru] [-CimSession <CimSession[]>] [-ThrottleLimit <Int32>] [-AsJob] [-WhatIf] [-Confirm] [<CommonParameters>]

Parameters of the New-NetIPAddress Command

The New-NetIPAddress command has the following parameters:

Parameter Description
-InterfaceIndex The index of the network interface to configure.
-IPAddress The IP address to configure.
-PrefixLength The prefix length of the IP address.
-DefaultGateway The default gateway of the IP address.
-AddressFamily The address family of the IP address.
-Type The type of IP address.
-PrefixOrigin The origin of the IP address prefix.
-SuffixOrigin The origin of the IP address suffix.
-SkipAsSource A switch that specifies whether the IP address should be excluded from source address selection.
-PolicyStore The policy store to use for the command.
-PassThru A switch that specifies whether the command should return an object.
-CimSession The CIM session to use for the command.
-ThrottleLimit The maximum number of concurrent operations that can be established to run the command.
-AsJob A switch that specifies whether the command should be run as a background job.
-WhatIf A switch that specifies whether the command should be run without making any changes.
-Confirm A switch that specifies whether the user should be prompted for confirmation before running the command.

Inputs for the New-NetIPAddress Command

The New-NetIPAddress command requires the following inputs:

  • The index of the network interface to configure.
  • The IP address to configure.
  • The prefix length of the IP address.
  • The default gateway of the IP address.
  • The address family of the IP address.
  • The type of IP address.
  • The origin of the IP address prefix.
  • The origin of the IP address suffix.
  • A switch that specifies whether the IP address should be excluded from source address selection.
  • The policy store to use for the command.

Outputs of the New-NetIPAddress Command

The New-NetIPAddress command produces the following outputs:

  • An object containing information about the IP address.
  • A message indicating whether the command was successful.

Examples of the New-NetIPAddress Command

The following examples demonstrate how to use the New-NetIPAddress command:

  • To create a new IP address, use the following command:

    New-NetIPAddress -InterfaceIndex 12 -IPAddress 192.168.1.1 -PrefixLength 24 -DefaultGateway 192.168.1.254 -AddressFamily IPv4 -Type Unicast -PrefixOrigin Manual -SuffixOrigin Manual -SkipAsSource False -PolicyStore ActiveStore

  • To modify an existing IP address, use the following command:

    New-NetIPAddress -InterfaceIndex 12 -IPAddress 192.168.1.2 -PrefixLength 24 -DefaultGateway 192.168.1.254 -AddressFamily IPv4 -Type Unicast -PrefixOrigin Manual -SuffixOrigin Manual -SkipAsSource False -PolicyStore ActiveStore

  • To delete an existing IP address, use the following command:

    New-NetIPAddress -InterfaceIndex 12 -IPAddress 192.168.1.2 -PrefixLength 24 -DefaultGateway 192.168.1.254 -AddressFamily IPv4 -Type Unicast -PrefixOrigin Manual -SuffixOrigin Manual -SkipAsSource False -PolicyStore ActiveStore -PassThru | Remove-NetIPAddress

Tips for Using the New-NetIPAddress Command

Here are some tips for using the New-NetIPAddress command:

  • Make sure you have the correct index for the network interface you want to configure.
  • Make sure you specify the correct IP address, prefix length, and default gateway.
  • Make sure you specify the correct address family, type, prefix origin, and suffix origin.
  • Make sure you specify the correct policy store.
  • If you want to delete an IP address, use the PassThru parameter and pipe the output to the Remove-NetIPAddress command.

Conclusion

The New-NetIPAddress command is a powerful tool for

Leave a Reply