我想将单位字节转换为千字节。
波纹管的powershell命令输入:
Get-WmiObject -class Win32_PerfFormattedData_Tcpip_NetworkInterface |
select BytesReceivedPersec , BytesSentPersec , name |
Where-Object {$_.name -cnotmatch "isatap"} |
Where-Object {$_.name -cnotmatch "Teredo"} |
Where-Object {$_.name -cnotmatch "로컬"} |
% { '{0,10} {1,20} {2,20}' -f $_.BytesReceivedPersec, $_.BytesSentPersec , $_.name}
输出:
627975 483072 Intel[R] 82575L Gigabit Network Connection
但输出单位是字节 我想将单位字节转换为千字节。
答案 0 :(得分:1)
将/1kb
添加到BytesReceived
表达式并用括号括起来:
Get-WmiObject -class Win32_PerfFormattedData_Tcpip_NetworkInterface |
select BytesReceivedPersec , BytesSentPersec , name |
Where-Object {$_.name -cnotmatch "isatap|Teredo|로컬"} |
% { '{0,10} {1,20} {2,20}' -f ($_.BytesReceivedPersec /1kb), ($_.BytesSentPersec /1kb) , $_.name}
您也可以使用-cnotmatch {"isatap|Teredo|로컬"}
来缩短代码