Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # First I have to get the old IP address details and store it somewhere...
- $OldIP = Get-NetIPAddress | Where IPAddress -like "192.168.*" | Where AddressFamily -like IPv4
- # Then I have to delete it completely - It doesn't look like I can just change the values?
- Remove-NetIPAddress -InterfaceIndex $OldIP.InterfaceIndex -AddressFamily $OldIP.AddressFamily;
- # This is the bit where I thought it was a bit overkill. I can't create the new address until I completely remove the
- # "NetRoute"/Gateway, whatever a netroute is, otherwise when I try and add it back in it says the Gateway already exists!
- Remove-NetRoute -InterfaceIndex $OldIP.InterfaceIndex;
- # And now I can finally add the new IP address in...
- New-NetIpAddress -InterfaceIndex $OldIP.InterfaceIndex -IPAddress 192.168.0.123 -PrefixLength 24 -AddressFamily IPv4 -DefaultGateway 192.168.0.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement