when i try to run this and change the ip address of a machine remotely, it disconnects before I can change the ip gateway. how can i get this working without getting disconnected?
$wmi = Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled = 'true'" -ComputerName sql2012
$wmi.EnableStatic("10.245.10.20", "255.255.0.0")
$wmi.SetGateways("10.245.0.1", 1)
$wmi.SetDNSServerSearchOrder("10.245.1.14")