0
我知道,工作代碼是Powershell查殺流程 - 我的字符串有什麼問題?
Get-Process firefo* | Stop-Process
但我的第一個猜測是
Get-Process | findstr firefox | Stop-Process
它沒有工作。
Stop-Process : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input. At line:1 char:33 + Get-Process | findstr firefox | Stop-Process + ~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: ( 1379 317... :PSObject) [Stop-Process], ParameterBindingException + FullyQualifiedErrorId : InputObjectNotBound,Microsoft.PowerShell.Commands.StopProcessCommand
據我所知,串
1342 306 1228412 1279864 -1671 ...71,42 35912 firefox
是壞的過程中殺死,但爲什麼呢?
PS C:\Users\adamg> Get-Process firefo*
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
1342 306 1228412 1279864 -1671 ...71,42 35912 firefox
上面的工作很好,即使列標題在回覆。
您必須查看cmdlet的'Get-Help -full'並查看Input和Output對象。 dos命令'findstr'只生成控制檯文本作爲輸出,不能用作Powershell cmdlet的輸入。 – user4317867