Export (0) Print
Expand All

New-NetIPAddress

Applies To: Windows Server 2012

New-NetIPAddress

Creates an IP address and the configuration properties of that IP address.

Syntax

Parameter Set: ByInterfaceAlias
New-NetIPAddress [-IPAddress] <String> -InterfaceAlias <String> [-AddressFamily <AddressFamily> ] [-AsJob] [-CimSession <CimSession[]> ] [-DefaultGateway <String> ] [-PolicyStore <String> ] [-PreferredLifetime <TimeSpan> ] [-PrefixLength <Byte> ] [-SkipAsSource <Boolean> ] [-ThrottleLimit <Int32> ] [-Type <Type> ] [-ValidLifetime <TimeSpan> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: ByInterfaceIndex
New-NetIPAddress [-IPAddress] <String> -InterfaceIndex <UInt32> [-AddressFamily <AddressFamily> ] [-AsJob] [-CimSession <CimSession[]> ] [-DefaultGateway <String> ] [-PolicyStore <String> ] [-PreferredLifetime <TimeSpan> ] [-PrefixLength <Byte> ] [-SkipAsSource <Boolean> ] [-ThrottleLimit <Int32> ] [-Type <Type> ] [-ValidLifetime <TimeSpan> ] [-Confirm] [-WhatIf] [ <CommonParameters>]




Detailed Description

The New-NetIPAddress cmdlet creates IP address and the configuration properties of that IP address. To create a specific IP address object, the required parameters include an IP address (IPv4 or IPv6) and an interface (InterfaceIndex or InterfaceAlias). It is also recommended to define the prefix length, also known as a subnet mask, and default gateway.

If DHCP is enabled on the interface to which this cmdlet is configured to, then DHCP will automatically be disabled.

Note: The DefaultGateway parameter sets a route to make the new IP address reachable. The Remove-NetIPAddress cmdlet will also remove this route provided the DefaultGateway parameter.

Parameters

-AddressFamily<AddressFamily>

Specifies an IP address family. This property is automatically generated if unspecified. The acceptable values for this parameter are: 
-- IPv4: IPv4 Address information.
-- IPv6: IPv6 address information.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-AsJob

Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete. The cmdlet immediately returns an object that represents the job and then displays the command prompt. You can continue to work in the session while the job completes. To manage the job, use the *-Job cmdlets. To get the job results, use the Receive-Job cmdlet. For more information about Windows PowerShell® background jobs, see about_Jobs.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-CimSession<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.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DefaultGateway<String>

Specifies the IPv4 address or IPv6 address of the default gateway for the host to use. Default gateways provide a default route for TCP/IP hosts to use when communicating with other hosts on remote networks.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-InterfaceAlias<String>

Specifies an IP interface for the IP address, as defined by the InterfaceAlias.


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

false

-InterfaceIndex<UInt32>

Specifies an IP interface for the IP address, as defined by the InterfaceIndex number.


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

false

-IPAddress<String>

Creates a specific IPv4 or IPv6 address.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

false

-PolicyStore<String>

Specifies the PolicyStore value. The acceptable values for this parameter are: 
-- ActiveStore: The IP address information is currently valid.
-- PersistentStore: The IP address information is persistent across reboots. When the computer starts, the PersistentStore settings are copied to the ActiveStore.
The default value is ActiveStore.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PreferredLifetime<TimeSpan>

Specifies a PreferredLifetime. PreferredLifetime uses time as defined by the TimeSpan structure.


Aliases

none

Required?

false

Position?

named

Default Value

Infinite

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PrefixLength<Byte>

Specifies a PrefixLength. The PrefixLength defines the local subnet size, and is also known as a subnet mask.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SkipAsSource<Boolean>

Specifies the SkipAsSource flag. SkipAsSource is used in a multiple IP address scenario in which the only the primary IP address for outgoing traffic. The IP addresses that have SkipAsSource set to True are not used for outgoing traffic and are not registered in DNS.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ThrottleLimit<Int32>

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.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Type<Type>

Specifies a specific IP address type. The acceptable values for this parameter are: 
-- Unicast: Marks the address as a unicast address.
-- Anycast: Marks the address as an anycast address.
The default value is Unicast.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ValidLifetime<TimeSpan>

Specifies the ValidLifetime. ValidLifetime uses time as defined by the TimeSpan structure.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • None

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Microsoft.Management.Infrastructure.CimInstance#root\StandardCimv2\MSFT_NetIPAddress

    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.


Examples

EXAMPLE 1

This command adds a new IPv4 address to the network interface at index 12. The subnet mask is determined by the PrefixLength parameter. In this example, the PrefixLength of 24 is equivalent to 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 you add.


 

PS C:\> New-NetIPAddress –InterfaceIndex 12 –IPAddress 192.168.0.1 -PrefixLength 24 -DefaultGateway 192.168.0.5

 

This command removes the IPv4 address. To remove the IPv4 address, use the Remove-NetIPAddress cmdlet.


PS C:\> Remove-NetIPAddress –IPAddress 192.168.0.1 -DefaultGateway 192.168.0.5

Related topics

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft