The VBScript Network and Systems Administrator's Cafe

Apr 9 2009   4:23PM GMT

Writing a BGINFO like Script: Displaying IP Address settings with WMI via the Win32_NetworkAdapterConfiguration class



Posted by: Jerry Lees
bginfo, Systems Administration, Systems administrator tools, systems management, systems reporting, VBScript, VBScript Functions

I recently had to provide the information displayed with BGINFO on a number of systems. Unfortunately, BGInfo only generates a bitmap, so far as I know, so I decided to write a script to generate the information and use this displayed information to send back to the person who requested it.

The function below is a part of the script I mentioned. It retrieves and returns text that represents the IP address settings for the network cards installed in a system.

You can view all the scripts in this BGINFO series here.

Here is the code:

Function GetIPAddresses(strComputer)
Dim colItems, objItem, address
Dim StrQuery
Dim objWMIService
Dim IP

StrQuery = “SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True”
Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\CIMV2″)
Set colItems = objWMIService.ExecQuery(strQuery,,48)

For Each objItem in colItems
For Each address In objItem.ipaddress
IP = replace(address,”:”,”")
‘IP = Replace(IP,vbnull,”No IP Assigned”)
GetIPAddresses = GetIPAddresses & vbTab & mid(objItem.caption,InStr(objItem.caption,”]”)+2) & “: ” & IP & vbcrLF
Next
Next
End Function

Comment on this Post

Leave a comment:

Srispa  |   Apr 17, 2009  12:23 PM (GMT)

Hi Jerry,
I exploring an option to get Oracle AS/OC4j istance service status using WMI. I have done some bits around getting windows services details. So, I would like to get Oracle AS services or/and OC4j instance service status as well.

Any help is heighly appriciated..


 

Jlees  |   Apr 17, 2009  2:08 PM (GMT)

That is something that is possible. What type of information do you need about the windows service?