Archive for April, 2011
Powershell script to configure a static ip address
0756 days
I came across a Powershell script to configure a static ip on a Windows machine. See below:
Don’t forget to make executionpolicy to be remotesigned using Set-ExecutionPolicy remotesigned -Confirm:$false -Force but you have to run the PowerShell console as Administrator.
$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration | where{$_.IPEnabled -eq "TRUE"}
Foreach($NIC in $NICs) {
$NIC.EnableStatic("192.168.100.66", "255.255.255.0")
$NIC.SetGateways("192.168.100.1")
$DNSServers = "192.168.100.2","192.168.100.3"
$NIC.SetDNSServerSearchOrder($DNSServers)
$NIC.SetDynamicDNSRegistration("FALSE")
}
