2

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

  • 1
    get a copy of MoW's powershell script "WMI Explorer". As the name implies, it is a GUI for exploring WMI. His blog where I would normally download it seems to be down, but this technet site has a copy of it: gallery.technet.microsoft.com/ScriptCenter/en-us/… – MattB May 26 '10 at 14:56
1

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.

Get-wmiobject Win32_NetworkAdapterConfiguration -filter IPEnabled=TRUE -computername localhost,127.0.0.1 | ForEach-Object -Process {
    Write-Host Server: $_.__SERVER
    Write-Host Adapter name: $_.Description
    Write-Host IP Addresses: $_.IPAddress
    Write-Host ""
}
1

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.

$nics = [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()
foreach ($nic in $nics) {
    write-host $nic.name
    $props = $nic.GetIPProperties()
    $addresses = $props.UnicastAddresses
    foreach ($addr in $addresses) {
        write-host "IP Address: $($addr.Address.IPAddressToString)"
        write-host "IPv4 Mask: $($addr.IPv4Mask.IPAddressToString)"
    }
    write-host "Gateway: $($props.GatewayAddresses.Address.IPAddressToString)"
    write-host "DNS Server(s): $($props.DnsAddresses.IPAddressToString)"
    write-host ""
}

See also the NetworkInterface class documentation.

1

Use the MSFT_NetIPAddress class instead.

Powershell Example:

gwmi MSFT_NetIPAddress -Namespace 'root/standardcimv2' | format-list -Property InterfaceAlias,IPAddress
  • This is the only method to look up a VNP "PPP adapter" of Windows 10. When connection is established, the adapter is present (as listed with DOS command IPConfig) and InterfaceAlias holds the name it was given in Windows. When the connection is down, the adapter is gone, thus will not be listed. – Gustav Feb 18 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.