< Back
Set-NetIPAddress
Post
NAME Set-NetIPAddress
SYNOPSIS
Modifies the configuration of an IP address.
SYNTAX
Set-NetIPAddress [[-IPAddress] <String[]>] [-AddressFamily <AddressFamily[]>] [-AddressState <AddressState[]>] [-CimSession <CimSession[]>]
[-IncludeAllCompartments] [-InterfaceAlias <String[]>] [-InterfaceIndex <UInt32[]>] [-PassThru] [-PolicyStore <String>] [-PreferredLifetime
<TimeSpan>] [-PrefixLength <Byte>] [-PrefixOrigin <PrefixOrigin[]>] [-SkipAsSource <Boolean>] [-SuffixOrigin <SuffixOrigin[]>] [-ThrottleLimit
<Int32>] [-Type <Type[]>] [-ValidLifetime <TimeSpan>] [-Confirm] [-WhatIf] [<CommonParameters>]
Set-NetIPAddress [-CimSession <CimSession[]>] [-PassThru] [-PreferredLifetime <TimeSpan>] [-PrefixLength <Byte>] [-SkipAsSource <Boolean>]
[-ThrottleLimit <Int32>] [-ValidLifetime <TimeSpan>] [-Confirm] [-WhatIf] [<CommonParameters>]
DESCRIPTION
The Set-NetIPAddress cmdlet modifies IP address configuration properties of an existing IP address.
To create an IPv4 address or IPv6 address, use the New-NetIPAddress cmdlet.
PARAMETERS
-AddressFamily [<AddressFamily[]>]
Specifies an array of IP address families. The cmdlet modifies the IP address configuration that matches the families. The acceptable values
for this parameter are:
-- IPv4
-- IPv6
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-AddressState [<AddressState[]>]
Specifies an array of duplicate address detection (DAD) state values for the IP address. The acceptable values for this parameter are:
-- Invalid. IP address configuration information for addresses that are not valid and will not be used.
-- Tentative. IP address configuration information for addresses that are not used for communication, as the uniqueness of those IP addresses
is being verified.
-- Duplicate. IP address configuration information for addresses for which a duplicate IP address has been detected and the current IP address
will not be used.
-- Deprecated. IP address configuration information for addresses that will no longer be used to establish new connections, but will continue
to be used with existing connections.
-- Preferred. IP address configuration information for addresses that are valid and available for use.
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.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-IncludeAllCompartments [<SwitchParameter>]
Indicates that the cmdlet includes addresses from all configured network compartments. If you do not specify this parameter, the cmdlet
modifies only addresses in the default network compartment.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-InterfaceAlias [<String[]>]
Specifies an array of aliases of network interfaces. The cmdlet modifies IP addresses that match the aliases.
Required? false
Position? named
Default value none
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-InterfaceIndex [<UInt32[]>]
Specifies an array of indexes of network interfaces. The cmdlet modifies IP addresses that match the indexes.
Required? false
Position? named
Default value none
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-IPAddress [<String[]>]
Specifies an array of IPv4 or IPv6 addresses.
Required? false
Position? 1
Default value none
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-PassThru [<SwitchParameter>]
Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-PolicyStore [<String>]
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.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-PreferredLifetime [<TimeSpan>]
Specifies a preferred lifetime, as a TimeSpan object, for an IP address. To obtain a TimeSpan object, use the New-TimeSpan cmdlet.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-PrefixLength [<Byte>]
Specifies a prefix length. This parameter defines the local subnet size, and is also known as a subnet mask.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-PrefixOrigin [<PrefixOrigin[]>]
ps_deprecate_para
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-SkipAsSource [<Boolean>]
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 address is not used for outgoing traffic and is not registered in DNS.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-SuffixOrigin [<SuffixOrigin[]>]
Specifies an array of origins for address suffixes. IP addresses are divided into two parts, the prefix and the suffix. The address prefix
identifies the network portion of an IP address, and the address suffix identifies the host portion. The acceptable values for this parameter
are:
-- Manual. The IP address suffix was manually specified.
-- WellKnown. The IP address suffix is from a well-known source.
-- DHCP. The IP address suffix was provided by DHCP settings.
-- Link. The IP address suffix was obtained from the link-layer address.
-- Random. The IP address suffix was obtained from a random source.
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.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-Type [<Type[]>]
Specifies an array of IP address types. The acceptable values for this parameter are:
-- Unicast
-- Anycast
The default value is Unicast.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-ValidLifetime [<TimeSpan>]
Specifies a valid lifetime, as a TimeSpan object, for an IP address. To obtain a TimeSpan object, use the New-TimeSpan cmdlet.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before running the cmdlet.Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value false
Accept pipeline input? false
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Shows what would happen if the cmdlet runs. The cmdlet is not run.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, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
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.
OUTPUTS
None
Example 1: Modify an IP address
PS C:\\> Set-NetIPAddress ????????InterfaceIndex 12 ????????IPAddress 192.168.0.1
PS C:\\> Set-NetIPAddress ????????InterfaceIndex 12 ????????IPAddress 192.168.0.1 ????????PrefixLength 24
This command adds the IP address 192.168.0.1 to the interface located at index 12.
The PrefixLength parameter may also be specified as part of the Set-NetIPAddress cmdlet.
Example 2: Modify an IP address and set the valid lifetime
PS C:\\> $Timesp = ( New-TimeSpan ????????Days 1 )
PS C:\\> Set-NetIPAddress ????????InterfaceIndex 12 ????????IPAddress 192.168.0.1 ????????PreferredLifetime $Timesp
The first command creates a new TimeSpan object of one day, and stores it in the variable named $Timesp.
The second command then uses the TimeSpan object to set the preferred lifetime of the IP address located at interface 12 to one day.
RELATED LINKS
Online Version: http://go.microsoft.com/fwlink/?LinkId=289165
New-TimeSpan
Get-NetIPAddress
New-NetIPAddress
Remove-NetIPAddress
SYNOPSIS
Modifies the configuration of an IP address.
SYNTAX
Set-NetIPAddress [[-IPAddress] <String[]>] [-AddressFamily <AddressFamily[]>] [-AddressState <AddressState[]>] [-CimSession <CimSession[]>]
[-IncludeAllCompartments] [-InterfaceAlias <String[]>] [-InterfaceIndex <UInt32[]>] [-PassThru] [-PolicyStore <String>] [-PreferredLifetime
<TimeSpan>] [-PrefixLength <Byte>] [-PrefixOrigin <PrefixOrigin[]>] [-SkipAsSource <Boolean>] [-SuffixOrigin <SuffixOrigin[]>] [-ThrottleLimit
<Int32>] [-Type <Type[]>] [-ValidLifetime <TimeSpan>] [-Confirm] [-WhatIf] [<CommonParameters>]
Set-NetIPAddress [-CimSession <CimSession[]>] [-PassThru] [-PreferredLifetime <TimeSpan>] [-PrefixLength <Byte>] [-SkipAsSource <Boolean>]
[-ThrottleLimit <Int32>] [-ValidLifetime <TimeSpan>] [-Confirm] [-WhatIf] [<CommonParameters>]
DESCRIPTION
The Set-NetIPAddress cmdlet modifies IP address configuration properties of an existing IP address.
To create an IPv4 address or IPv6 address, use the New-NetIPAddress cmdlet.
PARAMETERS
-AddressFamily [<AddressFamily[]>]
Specifies an array of IP address families. The cmdlet modifies the IP address configuration that matches the families. The acceptable values
for this parameter are:
-- IPv4
-- IPv6
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-AddressState [<AddressState[]>]
Specifies an array of duplicate address detection (DAD) state values for the IP address. The acceptable values for this parameter are:
-- Invalid. IP address configuration information for addresses that are not valid and will not be used.
-- Tentative. IP address configuration information for addresses that are not used for communication, as the uniqueness of those IP addresses
is being verified.
-- Duplicate. IP address configuration information for addresses for which a duplicate IP address has been detected and the current IP address
will not be used.
-- Deprecated. IP address configuration information for addresses that will no longer be used to establish new connections, but will continue
to be used with existing connections.
-- Preferred. IP address configuration information for addresses that are valid and available for use.
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.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-IncludeAllCompartments [<SwitchParameter>]
Indicates that the cmdlet includes addresses from all configured network compartments. If you do not specify this parameter, the cmdlet
modifies only addresses in the default network compartment.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-InterfaceAlias [<String[]>]
Specifies an array of aliases of network interfaces. The cmdlet modifies IP addresses that match the aliases.
Required? false
Position? named
Default value none
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-InterfaceIndex [<UInt32[]>]
Specifies an array of indexes of network interfaces. The cmdlet modifies IP addresses that match the indexes.
Required? false
Position? named
Default value none
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-IPAddress [<String[]>]
Specifies an array of IPv4 or IPv6 addresses.
Required? false
Position? 1
Default value none
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-PassThru [<SwitchParameter>]
Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-PolicyStore [<String>]
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.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-PreferredLifetime [<TimeSpan>]
Specifies a preferred lifetime, as a TimeSpan object, for an IP address. To obtain a TimeSpan object, use the New-TimeSpan cmdlet.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-PrefixLength [<Byte>]
Specifies a prefix length. This parameter defines the local subnet size, and is also known as a subnet mask.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-PrefixOrigin [<PrefixOrigin[]>]
ps_deprecate_para
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-SkipAsSource [<Boolean>]
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 address is not used for outgoing traffic and is not registered in DNS.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-SuffixOrigin [<SuffixOrigin[]>]
Specifies an array of origins for address suffixes. IP addresses are divided into two parts, the prefix and the suffix. The address prefix
identifies the network portion of an IP address, and the address suffix identifies the host portion. The acceptable values for this parameter
are:
-- Manual. The IP address suffix was manually specified.
-- WellKnown. The IP address suffix is from a well-known source.
-- DHCP. The IP address suffix was provided by DHCP settings.
-- Link. The IP address suffix was obtained from the link-layer address.
-- Random. The IP address suffix was obtained from a random source.
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.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-Type [<Type[]>]
Specifies an array of IP address types. The acceptable values for this parameter are:
-- Unicast
-- Anycast
The default value is Unicast.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-ValidLifetime [<TimeSpan>]
Specifies a valid lifetime, as a TimeSpan object, for an IP address. To obtain a TimeSpan object, use the New-TimeSpan cmdlet.
Required? false
Position? named
Default value none
Accept pipeline input? false
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before running the cmdlet.Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value false
Accept pipeline input? false
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Shows what would happen if the cmdlet runs. The cmdlet is not run.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, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
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.
OUTPUTS
None
Example 1: Modify an IP address
PS C:\\> Set-NetIPAddress ????????InterfaceIndex 12 ????????IPAddress 192.168.0.1
PS C:\\> Set-NetIPAddress ????????InterfaceIndex 12 ????????IPAddress 192.168.0.1 ????????PrefixLength 24
This command adds the IP address 192.168.0.1 to the interface located at index 12.
The PrefixLength parameter may also be specified as part of the Set-NetIPAddress cmdlet.
Example 2: Modify an IP address and set the valid lifetime
PS C:\\> $Timesp = ( New-TimeSpan ????????Days 1 )
PS C:\\> Set-NetIPAddress ????????InterfaceIndex 12 ????????IPAddress 192.168.0.1 ????????PreferredLifetime $Timesp
The first command creates a new TimeSpan object of one day, and stores it in the variable named $Timesp.
The second command then uses the TimeSpan object to set the preferred lifetime of the IP address located at interface 12 to one day.
RELATED LINKS
Online Version: http://go.microsoft.com/fwlink/?LinkId=289165
New-TimeSpan
Get-NetIPAddress
New-NetIPAddress
Remove-NetIPAddress