PowerTip: Find Information about Network Adapters with PowerShell

PowerTip: Find Information about Network Adapters with PowerShell

  • Comments 5
  • Likes

Summary: Use Windows PowerShell in Windows 8 to find information about network adapters.

Hey, Scripting Guy! Question In Windows 8, how can I find information about network adapters?

Hey, Scripting Guy! Answer Use the Get-NetAdapter function:

Get-NetAdapter

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • In PoSh v2:

    (gwmi win32_networkadapter) | %{ new-object pscustomobject -pro @{'name' = $_.name; 'MAC' = $_.macaddress; 'Last Reset'= $_.converttodatetime($_.TimeOfLastReset); 'Description' = $_.NetConnectionID; 'PHY-or-VIRTUAL' = $_.PhysicalAdapter}} | ft -auto

  • It is not necessary to generate objects when you already have objects.  The habit only adds unnecessary complexity to the task.  Use your object and manipulate its outcome. Faster - cleaner.

    gwmi win32_networkadapter |

        select Name,MacAddress,NetConnectionID,PhysicalAdapter,

               @{N='LastReset';E={$_.ConvertToDateTime($_.timeoflastreset)}}

    Also- it's a pipeline.  One-liners do not have to be written all on one line.  Format for clarity.

  • @jrv while i will take your comments, i will have to respectfully disagree:

    1. Complexity...there's no such thing, its just layers of simplicity

    2. whitespace is a waist

    3. Cleaner?... if you don't know what your reading i could make it the cleanest possible code in the world, you still wouldn't know whats going on. So to say make it more "Readable" or "Clean" is ridiculous. if you know PoSh then its readable, its clean, by the mere fact that there is alphabetic symbols on a screen and you have grouped them into words and phrases. I'm not writing a book or teaching a PEBKAC, if your reading this blog i would assume you know PoSh already (in some variation)

    4. i will agree that using select would have been better. Sorry i was using the same line i found in the post 'Weekend Scripter: Use PowerShell to Find Auto-Connect Wireless Networks'

  • i wrote waist when it was suppose to be waste.

    Sorry i believe i have ruined my argument already.. so no one pay attention to the *** who cant spell

  • The standards and practices of good programming do apply.

    Mostly I was noting to ALL that the construct was overly complicated without necessity.

    KISS!