Network adapters

This topic contains 7 replies, has 4 voices, and was last updated by Profile photo of Simon B Simon B 2 weeks, 3 days ago.

  • Author
    Posts
  • #74603
    Profile photo of Tony
    Tony
    Participant

    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
  • #74615
    Profile photo of Will Anderson
    Will Anderson
    Keymaster

    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
    Profile photo of Tony
    Tony
    Participant

    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
    Profile photo of Will Anderson
    Will Anderson
    Keymaster

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

  • #74665
    Profile photo of Will Anderson
    Will Anderson
    Keymaster

    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
    Profile photo of Tony
    Tony
    Participant

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

  • #74678
    Profile photo of Simon B
    Simon B
    Participant

    if you add sort description on the end

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

You must be logged in to reply to this topic.