Skip to content

Instantly share code, notes, and snippets.

@alicraigmile
Created April 16, 2014 21:21
Show Gist options
  • Save alicraigmile/10934319 to your computer and use it in GitHub Desktop.
Save alicraigmile/10934319 to your computer and use it in GitHub Desktop.
Retrieve IP addresses of each active network adapter on a Windows workstation
'Get all of the IP Addresses assigned to this workstation
Function GetIPAddress ()
Dim Count, line, IPAddress, myObj
Rem Start by finding the IP address
Set myObj = GetObject("winmgmts:{impersonationLevel=impersonate}!//localhost").ExecQuery("select IPAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
Count = 0
For each IPAddress in myObj
Count = Count + 1
Next
ReDim IPAddr(Count - 1)
Count = 0
'Format Results
For each IPAddress in myObj
IPAddr(Count) = IPAddress.IPAddress(0)
Count = Count + 1
Next
getIPAddress = IPAddr
End Function
Dim List
List = GetIPAddress()
for each IPAddress in List
wscript.echo "IP Address:" & IPAddress
next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment