Win32_NetworkAdapterConfiguration Loop through W2K machines

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I have knocked up a script to retrieve IP info from an array of machines. It
works fine as long as every machine is Windows 2003 or Windows XP, but if
there is anything of an earlier OS in the array the results are repeated. So
for an array with 3 W2k machines (or NT with WMICORE installed) every PC /
Server will produce the same results. Any suggestions would be welcome.
Script below:

Option Explicit
On Error Resume Next
Dim arrComputers, strComputer, objWMIService, colItems
Dim objItem, strDefaultIPGateway, strIPAddress

arrComputers =
Array("computer1","computer2","computer3","computer4","computer5")
For Each strComputer In arrComputers
WScript.Echo
WScript.Echo "=========================================="
WScript.Echo "Computer: " & strComputer
WScript.Echo "=========================================="

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_NetworkAdapterConfiguration where IPEnabled = True", , 48)

For Each objItem In colItems
strDefaultIPGateway = Join(objItem.DefaultIPGateway, ",")
WScript.Echo "DefaultIPGateway: " & strDefaultIPGateway
WScript.Echo "DHCPServer: " & objItem.DHCPServer
strIPAddress = Join(objItem.IPAddress, ",")
WScript.Echo "IPAddress: " & strIPAddress
strIPSubnet = Join(objItem.IPSubnet, ",")
WScript.Echo "IPSubnet: " & strIPSubnet
WScript.Echo "MACAddress: " & objItem.MACAddress
WScript.Echo "WINSPrimaryServer: " & objItem.WINSPrimaryServer
WScript.Echo "WINSSecondaryServer: " & objItem.WINSSecondaryServer
WScript.Echo
Next
Next

--
Mark Salter
Senior ICT Officer
Rhondda Cynon Taf County Borough Council
.


Quantcast