The New-NetIPAddress cmdlet creates and configures an IP address.
To create a specific IP address object, specify either an IPv4 address or an IPv6 address, and an interface index or interface alias.
We recommend that you define the prefix length, also known as a subnet mask, and a default gateway.
If you run this cmdlet to add an IP address to an interface on which DHCP is already enabled, then DHCP is automatically disabled.
If Duplicate Address Detection (DAD) is enabled on the interface, the new IP address is not usable until DAD successfully finishes, which confirms the uniqueness of the IP address on the link.
The first command adds a new IPv4 address to the network interface at index 12.
The PrefixLength parameter specifies the subnet mask for the IP address.
In this example, the PrefixLength of 24 equals a subnet mask of 255.255.255.0.
When you add an IPv4 address, the address specified for the Default Gateway must be in the same subnet as the IPv4 address that you add.
The second command removes the IPv4 address. To remove the IPv4 address, use the Remove-NetIPAddress cmdlet.
Parameters
-AddressFamily
Specifies an IP address family.
The cmdlet creates an IP address for the family.
If you do not specify this parameter, the property is automatically generated.
The acceptable values for this parameter are:
IPv4
IPv6
Parameter properties
Type:
AddressFamily
Default value:
None
Accepted values:
IPv4, IPv6
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-AsJob
Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-CimSession
Runs the cmdlet in a remote session or on a remote computer.
Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet.
The default is the current session on the local computer.
Parameter properties
Type:
CimSession[]
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
Session
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type:
SwitchParameter
Default value:
False
Supports wildcards:
False
DontShow:
False
Aliases:
cf
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-DefaultGateway
Specifies the IPv4 address or IPv6 address of the default gateway for the host.
Default gateways provide a default route for TCP/IP hosts to use when communicating with other hosts on remote networks.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-InterfaceAlias
Specifies an alias of a network interface.
The cmdlet creates an IP address for the alias.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
ifAlias
Parameter sets
ByInterfaceAlias
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-InterfaceIndex
Specifies an index of a network interface.
The cmdlet creates an IP address for the index.
Parameter properties
Type:
UInt32
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
ifIndex
Parameter sets
ByInterfaceIndex
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-IPAddress
Specifies the IPv4 or IPv6 address to create.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
LocalAddress
Parameter sets
(All)
Position:
0
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-PolicyStore
Specifies a PolicyStore value.
The acceptable values for this parameter are:
-- ActiveStore.
The IP address information is valid.
-- PersistentStore.
The computer saves IP address information across restarts.
When the computer restarts, it copies the saved settings to the ActiveStore.
The default value is ActiveStore.
Specify ActiveStore only.
If you do not specify this parameter, the default entries are created in both the ActiveStore and the PersistentStore.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-PreferredLifetime
Specifies a preferred lifetime, as a TimeSpan object, for an IP address.
To obtain a TimeSpan object, use the New-TimeSpan cmdlet.
Parameter properties
Type:
TimeSpan
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-PrefixLength
Specifies a prefix length.
This parameter defines the local subnet size, and is also known as a subnet mask.
Parameter properties
Type:
Byte
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-SkipAsSource
Indicates whether an address is a primary IP address.
This parameter identifies the primary IP address for outgoing traffic in a multiple IP address scenario.
If this parameter is set to True, the addresses are not used for outgoing traffic and are not registered in DNS.
Parameter properties
Type:
Boolean
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-ThrottleLimit
Specifies the maximum number of concurrent operations that can be established to run the cmdlet.
If this parameter is omitted or a value of 0 is entered, then Windows PowerShell® calculates an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running on the computer.
The throttle limit applies only to the current cmdlet, not to the session or to the computer.
Parameter properties
Type:
Int32
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Type
Specifies an IP address type.
The acceptable values for this parameter are:
-- Unicast
-- Anycast
The default value is Unicast.
Parameter properties
Type:
Type
Default value:
None
Accepted values:
Unicast, Anycast
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-ValidLifetime
Specifies a valid lifetime value, as a TimeSpan object, for an IP address.
To obtain a TimeSpan object, use the New-TimeSpan cmdlet.
Parameter properties
Type:
TimeSpan
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
Parameter properties
Type:
SwitchParameter
Default value:
False
Supports wildcards:
False
DontShow:
False
Aliases:
wi
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters.
The Microsoft.Management.Infrastructure.CimInstance object is a wrapper class that displays Windows Management Instrumentation (WMI) objects.
The path after the pound sign (#) provides the namespace and class name for the underlying WMI object.