PowerShell Logo Small

Set-NetIPAddress



This is the built-in help made by Microsoft for the command 'Set-NetIPAddress', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Modifies the configuration of an IP address.

SYNTAX


Set-NetIPAddress [[-IPAddress] <String[]>] [-AddressFamily <AddressFamily[]>] [-AddressState <AddressState[]>] [-AsJob] [-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 [-AsJob] [-CimSession <CimSession[]>] [-PassThru] [-PreferredLifetime <TimeSpan>] [-PrefixLength <Byte>] [-SkipAsSource <Boolean>] [-ThrottleLimit <Int32>]
[-ValidLifetime <TimeSpan>] -InputObject <CimInstance[]> [-Confirm] [-WhatIf] [<CommonParameters>]



Search powershellhelp.space

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.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkId=289165
New-TimeSpan
Get-NetIPAddress
New-NetIPAddress
Remove-NetIPAddress

REMARKS

<

Examples


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.