Get VPN IP Address through WMI in Vista

How can we list all network connections in order to extract the IP address of the VPN connection using WMI? In XP, Win32_NetworkAdapterConfiguration works fine, but in Vista it only seems to list physical connections ...

+4
source share
2 answers

If you look at the Win32_NetworkAdapterConfiguration documentation comments , you will see a link to Win32_NetworkAdapter when working with Vista.

'Vista only code??? Set colAdapters = objWMIService.Execquery ("SELECT * FROM Win32_NetworkAdapter WHERE NetEnabled = True") For Each nic in colAdapters msg = "nic.DeviceId: " & nic.DeviceId & vbCRLF _ & "nic.Name: " & nic.Name & vbCRLF _ Next 

From this, you can get InterfaceIndex and find the IP address from the Win32_IP4RouteTable class.

This is certainly a roundabout way to get information compared to using Win32_NetworkAdapterConfiguration .

0
source

Found it in MSFT classes! Specific implementation of the CIM interface object: gwmi msft_netIPAddress -Namespace 'root / standardcimv2' | format-list -Property InterfaceAlias, IPAddress

0
source