Advertisement
Guest User

Untitled

a guest
Oct 11th, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # First I have to get the old IP address details and store it somewhere...
  2. $OldIP = Get-NetIPAddress | Where IPAddress -like "192.168.*" | Where AddressFamily -like IPv4
  3.  
  4. # Then I have to delete it completely - It doesn't look like I can just change the values?
  5. Remove-NetIPAddress -InterfaceIndex $OldIP.InterfaceIndex -AddressFamily $OldIP.AddressFamily;
  6.  
  7. # This is the bit where I thought it was a bit overkill. I can't create the new address until I completely remove the
  8. # "NetRoute"/Gateway, whatever a netroute is, otherwise when I try and add it back in it says the Gateway already exists!
  9. Remove-NetRoute -InterfaceIndex $OldIP.InterfaceIndex;
  10.  
  11. # And now I can finally add the new IP address in...
  12. 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