Sets all network interfaces (NICS) to aquire their IP address by DHCP on the specified computer.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\" & strComputer & "
ootcimv2")
Set colNicConfs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
strStatus = ""
For Each objNicConf In colNicConfs
strStatus = strStatus & "Network Adapter: " & objNicConf.Index & VbCrLf & objNicConf.Description & VbCrLf
If Not objNicConf.DHCPEnabled Then
WScript.Echo " Enabling DHCP ..."
intStatus = objNicConf.EnableDHCP
If intStatus = 0 Then
strStatus = strStatus & " - DHCP enabled successfully"
Else
strStatus = strStatus & " - Cannot enable DHCP"
End If
Else
strStatus = strStatus & "DHCP already enabled with Server: " & objNicConf.DHCPServer
End If
strStatus = strStatus & VbCrLf & VbCrLf
Next
Wscript.Echo strStatus