PowerShell script helps you to configure static IP on localmachine

This PowerShell script helps you to configure static IP on localmachine, just copy the code and past it in txt file then rename it to anyname.ps1 “static.ps1″

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")
}

Comments

  • Anonymous
    January 01, 2003
    This script is already tested

  • Anonymous
    April 25, 2011
    In an ideal world this script would almost work but I'm not sure if I'd call this script ready for prime time,  

  • Anonymous
    April 27, 2011
    Sorry the fact that your setting all nics to the same ip settings seems to be an issue. tr