WMI returning arrays

If you have information, script, utility, or idea that can be useful for HostMonitor community, you welcome to share information in this forum.
Post Reply
grussell
Posts: 36
Joined: Thu Jan 21, 2010 2:24 am

WMI returning arrays

Post by grussell »

Hi - I'm trying to use WMI to obtain the IP address using

select IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE' AND Index=1

But an array is returned - how do I pull the IP address from this in AHM?

Many thanks,

Gavin.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

There is no such option. HostMonitor shows just one value, it does not publish arrays.

Regards
Alex
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Please use this forum when you have some useful script, application etc that can be useful for everyone.
E.g. you can create VBScript to request WMI arrays then publish this script in this forum.

Regards
Alex
grussell
Posts: 36
Joined: Thu Jan 21, 2010 2:24 am

Shell Script to get single WMI value from array

Post by grussell »

Option Explicit

const statusAlive = "scriptRes:Host is alive:"
const statusDead = "scriptRes:No answer:"
const statusUnknown = "scriptRes:Unknown:"
const statusNotResolved = "scriptRes:Unknown host:"
const statusOk = "scriptRes:Ok:"
const statusBad = "scriptRes:Bad:"
const statusBadContents = "scriptRes:Bad contents:"

'---- entry point ----
dim objWMIService, wbemObjectSet,wbemObject, strIPAddresses
Set objWMIService = GetObject("winmgmts:")
Set wbemObjectSet = objWMIService.ExecQuery("SELECT * FROM " & _
"Win32_NetworkAdapterConfiguration WHERE Index=1 AND IPEnabled = True")
For Each wbemObject In wbemObjectSet

If Not IsNull(wbemObject.IPAddress) Then
strIPAddresses = Join(wbemObject.IPAddress)
Else
strIPAddresses = ""
End If
wscript.stdout.write statusOk
WScript.StdOut.Write strIPAddresses
next
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Thank you

Regards
Alex
Post Reply