How can I use a script to generate a list of all IP addresses on a machine?

John Savill

September 9, 2005

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A. The following script will write to screen each IP address on a client.

Option Explicit Dim IPConfigSet, IPConfig, iset IPConfigSet = GetObject("winmgmts:{impersonationLevel=impersonate}!rootcimv2").ExecQuery("SELECT IPAddress, DefaultIPGateway FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE")for each IPConfig in IPConfigSet  if Not IsNull(IPConfig.IPAddress) then     wscript.echo IPConfig.IPAddress(i)  end ifnext

The output below shows a sample execution.

D:temp>cscript listip.vbsMicrosoft (R) Windows Script Host Version 5.6Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.10.10.15.105192.168.1.57

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like