Getting configurations for physical network adapters

Teaching class in rainy Atlanta this week, and a question came up: How can I get the network adapter configuration for just the real, physical network adapters? Here's one way.

get-wmiobject -class win32_networkadapterconfiguration | where-object { (get-wmiobject -class win32_networkadapter -filter "physicaladapter=true" | select -expand name) -contains $_.description }

Discuss this Blog Entry 2

on Oct 7, 2011
Both ways don't process particularly fast. If you're looking for more speed, this quick and dirty function should help. function Get-PhysicalNetAdapterConfiguration { [CmdletBinding()] param ( [Parameter(Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [Alias('Name')] [string]$ComputerName = '.' ) process { try { $netAdapters = Get-WmiObject -Class Win32_NetworkAdapter -Filter "PhysicalAdapter = '$true' " -ComputerName $ComputerName -ErrorAction Stop } catch { return Write-Error $_ } foreach ($netAdapter in $netAdapters) { $netAdapter.GetRelated('Win32_NetworkAdapterConfiguration') } } # process }
on Oct 6, 2011
Great tip Don. Here's another way requiring a bit less typing. Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Where-Object {$_.GetRelated() | Select-Object -ExpandProperty PhysicalAdapter}

Please or Register to post comments.

What's PowerShell with a Purpose Blog?

Don Jones demystifies Windows PowerShell.

Blog Archive

Sponsored Introduction Continue on to (or wait seconds) ×