Network adapters

Welcome Forums General PowerShell Q&A Network adapters

This topic contains 7 replies, has 4 voices, and was last updated by

 
Participant
1 year, 4 months ago.

  • Author
    Posts
  • #74603

    Participant
    Points: 0
    Rank: Member

    Hi, I've been struggling with this for about a week and I'm hoping someone one can share an example that I can build from. I'm trying to get the ip addresses of all active network adapters on a local computer and list them respectively (Wireless, VPN and Wired Connection). Thanks for any help in advance.

  • #74609

    Participant
    Points: -12
    Rank: Member
  • #74615

    Keymaster
    Points: 12
    Team Member
    Rank: Member

    I've only got the one operational adapter on mine. Try this. It's a little more elegant.
    $NetAdapter = (Get-NetAdapter).where({$PSItem.Status -eq 'Up'})
    (Get-NetIPAddress).where({$PSItem.InterfaceAlias -eq $NetAdapter.InterfaceAlias})

  • #74620

    Participant
    Points: 0
    Rank: Member

    Thanks but I cant get the Get-NetAdapter to work. The computers I work on are windows 7. Looks like that isn't available unless I upgrade to win 8.

  • #74626

    Keymaster
    Points: 12
    Team Member
    Rank: Member

    How about: (Get-WmiObject -Class Win32_NetworkAdapterConfiguration).where({$PSItem.IPAddress -ne $null})

  • #74665

    Keymaster
    Points: 12
    Team Member
    Rank: Member

    Also, I just realized that the where method isn't available if you're on straight PowerShell 2, so here would be something more appropriate.

    Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where-Object IPAddress -ne $null

    My bad.

  • #74675

    Participant
    Points: 0
    Rank: Member

    Thanks that definitely gets me closer. Is there a way to separate them or label them as wireless, wired, vpn?

  • #74678

    Participant
    Points: 13
    Rank: Member

    if you add sort description on the end

    Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where-Object IPAddress -ne $nul |sort description

The topic ‘Network adapters’ is closed to new replies.