View previous topic :: View next topic |
Author |
Message |
grussell
Joined: 21 Jan 2010 Posts: 36
|
Posted: Sat Jan 30, 2010 12:36 pm Post subject: WMI returning arrays |
|
|
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. |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12805 Location: USA
|
Posted: Sat Jan 30, 2010 3:47 pm Post subject: |
|
|
There is no such option. HostMonitor shows just one value, it does not publish arrays.
Regards
Alex |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12805 Location: USA
|
Posted: Sat Jan 30, 2010 3:48 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
grussell
Joined: 21 Jan 2010 Posts: 36
|
Posted: Mon Feb 01, 2010 6:13 am Post subject: Shell Script to get single WMI value from array |
|
|
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 |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12805 Location: USA
|
Posted: Mon Feb 01, 2010 4:10 pm Post subject: |
|
|
Thank you
Regards
Alex |
|
Back to top |
|
|
|