Created
April 16, 2014 21:21
-
-
Save alicraigmile/10934319 to your computer and use it in GitHub Desktop.
Retrieve IP addresses of each active network adapter on a Windows workstation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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