從`netstat`指令中的規定值,當我運行命令netstat -ano
我:獲取窗口
PS Y:\PowerShell> netstat -ano
Active Connections
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 376
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:2222 0.0.0.0:0 LISTENING 2364
TCP 0.0.0.0:3389 0.0.0.0:0 LISTENING 1748
TCP 0.0.0.0:5985 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:6081 0.0.0.0:0 LISTENING 2556
TCP 0.0.0.0:8001 0.0.0.0:0 LISTENING 3772
TCP 0.0.0.0:47001 0.0.0.0:0 LISTENING 4
但我真正想要得到的是:
活動連接
PID
4
376
4
2364
1748
4
2556
3772
4
我不能使用:netstat -ano| select PID
,因爲它不是powershell命令。
'netstat -ano |選擇-Skip 4 | ConvertFrom-String -PropertyNames「_」,「Proto」,「Local Address」,「Foreign Address」,「State」,「PID」選擇PID'。 ['ConvertFrom-String'](https://msdn.microsoft.com/powershell/reference/5.1/microsoft.powershell.utility/convertfrom-string)是一個聰明的cookie。 –
@JeroenMostert tks,但是如何導入ConvertFrom-String? – Ender
'ConvertFrom-String'是PowerShell 3的內建版。 –