Created
May 29, 2012 22:00
-
-
Save clly/2831066 to your computer and use it in GitHub Desktop.
Set Windows DNS and IP addressing to use DHCP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
strComputer = "." | |
Set objWMIService = GetObject("winmgmts:" _ | |
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") | |
Set colNicConfigs = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") | |
For Each obj in colNicConfigs | |
obj.SetDNSServerSearchOrder(null) | |
if not obj.DHCPEnabled Then | |
obj.EnableDHCP | |
End if | |
Next |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment