powershell - 输出微调

powershell - output trimming

我正在尝试读取网络适配器速度设置的有效值,但 PowerShell 似乎没有输出所有内容。根据 GUI 网络适配器设置 window,PowerShell 输出值列表中缺少“100 Mbps 全双工”和“1000Mbps 全双工”。

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...}

我试过 ft out-stringwrite-host 但没有任何运气。如何输出完整列表?

更新:我已尝试将 GUI view 添加到我的网络适配器速度设置中,以便更好地了解我的问题。

我认为您正在寻找 Select-Object

的 -ExpandProperty
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

但更通用的查找是使用注册表名称而不是 DisplayName(应该是本地化的)。

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