I am trying to get the IP of a PPP VPN network connection, but Win32_NetworkAdapterConfiguration does not seem to "see" it.
If I interrogate all adapters using my script, it will see everything but the PPP VPN adapter. Is there a specific filter or something I need to enable, or do I need a different class?
My Script:
$colItems = Get-wmiobject Win32_NetworkAdapterConfiguration
foreach ($objItem in $colItems) {
Write-Host Description: $objItem.Description
Write-Host IP Address: $objItem.IPAddress
Write-Host ""
}
Script Output:
Description: WAN Miniport (SSTP)
IP Address:
Description: WAN Miniport (IKEv2)
IP Address:
Description: WAN Miniport (L2TP)
IP Address:
Description: WAN Miniport (PPTP)
IP Address:
Description: WAN Miniport (PPPOE)
IP Address:
Description: WAN Miniport (IPv6)
IP Address:
Description: WAN Miniport (Network Monitor)
IP Address:
Description: Intel(R) PRO/Wireless 3945ABG Network Connection
IP Address: 192.168.2.5
Description: WAN Miniport (IP)
IP Address:
ipconfig /all output:
PPP adapter My VPN:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : My VPN
Physical Address. . . . . . . . . :
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 10.1.8.12(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.255
Default Gateway . . . . . . . . . : 0.0.0.0
DNS Servers . . . . . . . . . . . : 10.1.1.3
10.1.1.2
Primary WINS Server . . . . . . . : 10.1.1.2
Secondary WINS Server . . . . . . : 10.1.1.3
NetBIOS over Tcpip. . . . . . . . : Enabled
Wireless LAN adapter Wireless Network Connection:
Connection-specific DNS Suffix . : Belkin
Description . . . . . . . . . . . : Intel(R) PRO/Wireless 3945ABG Network Connection
Physical Address. . . . . . . . . : 00-3F-3C-22-22-22
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 192.168.2.5(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : 25 May 2010 20:33:19
Lease Expires . . . . . . . . . . : 22 May 2020 20:33:17
Default Gateway . . . . . . . . . : 192.168.2.1
DHCP Server . . . . . . . . . . . : 192.168.2.1
DNS Servers . . . . . . . . . . . : 192.168.2.1
NetBIOS over Tcpip. . . . . . . . : Enabled
Thanks in advance,
Ben
I know that this is a very old thread, still I'll post the way I manage it so it could help someone like me, as I couldn't find a ready solution.
What this does is loop through several hosts and their NICs. It shows ALL NIC IPs but not a default one.
This is a bug that was present in Vista and hasn't gotten fixed through Windows 7 or Windows 8. You have to call the .NET API directly from Powershell to get this information.
See also the NetworkInterface class documentation.
Use the MSFT_NetIPAddress class instead.
Powershell Example: