Home > front end >  powershell - output trimming
powershell - output trimming

Time:09-21

I am trying to read valid values of network adapter speed settings, but it looks like PowerShell does not output everything. According to the GUI network adapter settings window, there is '100 Mbps Full Duplex' and '1000Mbps Full Duplex' missing in the list of PowerShell outputted values.

PS> Get-NetAdapterAdvancedProperty Ethernet -Displayname 'Link Speed & Duplex' | fl ValidDisplayValues

ValidDisplayValues : {Auto Negotiation, 10 Mbps Half Duplex, 10 Mbps Full Duplex, 100 Mbps Half Duplex...}

I've tried to play with ft out-string and write-host but haven't had any luck. How do I output a complete list?

UPDATE: I've tried adding GUI view to my network adapter speed settings for better understanding of my problem.

CodePudding user response:

I think you are looking for -ExpandProperty of Select-Object

Get-NetAdapterAdvancedProperty | where DisplayName -like '*speed*' | 
select -first 1 -ExpandProperty ValidDisplayValues

Auto Negotiation
10 Mbps Half Duplex
10 Mbps Full Duplex
100 Mbps Half Duplex
100 Mbps Full Duplex
1.0 Gbps Full Duplex

But a more generic lookup would be using the Registry name instead of DisplayName (that are supposed to be localized).

Get-NetAdapterAdvancedProperty | where RegistryKeyWord -eq '*SpeedDuplex' | 
select -ExpandProperty ValidDisplayValues
  • Related