Nitrous270
Technical User
I'm pulling in a IPAddress using WMI and then I'd like to convert the IP Octets into an array. I'm having trouble creating the array. I'm probably missing something simple but I can't seem to figure this out.
Can someone explain why this doesn't work
strIPAddress="192.168.0.1"
arrIP= Array(Replace(strIPAddress, ".", ","))
wscript.echo arrIP(2)
ECHO 192.168.0.1
However this does work,
arrIP=Array(192,168,0,1)
wscript.echo arrIP(2)
ECHO 0
Here is the whole code
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery("SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each objAdapter In colAdapters
strIPAddress = objAdapter.IPAddress(0)
msgbox strIPAddress
Next
arrIP= Array(Replace(strIPAddress, ".", ","))
wscript.echo arrIP(2)
Set colAdapters = Nothing
Set objWMIService = Nothing
Thanks for the help,
Ryan
Can someone explain why this doesn't work
strIPAddress="192.168.0.1"
arrIP= Array(Replace(strIPAddress, ".", ","))
wscript.echo arrIP(2)
ECHO 192.168.0.1
However this does work,
arrIP=Array(192,168,0,1)
wscript.echo arrIP(2)
ECHO 0
Here is the whole code
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery("SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each objAdapter In colAdapters
strIPAddress = objAdapter.IPAddress(0)
msgbox strIPAddress
Next
arrIP= Array(Replace(strIPAddress, ".", ","))
wscript.echo arrIP(2)
Set colAdapters = Nothing
Set objWMIService = Nothing
Thanks for the help,
Ryan