Starting with Windows Server 2012, you can now handle directly the IP configuration with PowerShell cmdlets.
Unfortunately, there is no cmdlet which directly updates an already existing IP address. You have to use four of them.
Please be aware that you will disconnect yourself from the computer if you do this operation remotely. This won’t happen if you use PowerShell Direct or a VM console.
Main steps
- Find the index of the interface hosting the current IP address
Get-NetIPAddress -IPAddress '192.168.100.156'
- Remove this IP address from the persistent store.
Remove-NetIPAddress -IPAddress '192.168.100.156'
- Create a new IP address entry
New-NetIPAddress -InterfaceIndex 12 -AddressFamily IPv4 -IPAddress '192.168.0.50' -PrefixLength 24
- If the gateway is different from the former one, remove it, and set a new one
Remove-NetRoute -InterfaceIndex 12 -NextHop 192.168.100.1 New-NetRoute -InterfaceIndex 12 -DestinationPrefix '0.0.0.0/0' -AddressFamily IPv4 -NextHop '192.168.0.254' -RouteMetric 0
- If the DNS server has changed, set the interface’s DNS server
Set-DnsClientServerAddress -InterfaceIndex 12 -ServerAddresses 192.168.0.254
More about
An explanation of the Automatic Metric feature for IPv4 routes (Microsoft Support)
IP Routing Table (Microsoft Technet)