Pur*_*lot 1 parameters powershell
我想停止名为“ALG”的服务,所以我使用:"alg" | stop-service
有用。
Get-help stop-service -parameter name
说:
Pipeline input:true(ByPropertyName, ByValue)
而“alg”是“ByPropertyValue”,对吗?
我想停止名为记事本的进程,因此我使用:"notepad" | stop-process
并且收到错误。
Get-help stop-process -parameter name
说:Pipeline input true(ByPropertyName)
“记事本”是“ByPropertyName”?
为什么会出现这个错误?
如果您想通过属性名称将对象的值绑定到参数,可以:
[pscustomobject]@{Name='notepad'} |Stop-Process
# or, for older versions of powershell:
'notepad' |Select @{Name='Name';Expression={$_}} |Stop-Process
Run Code Online (Sandbox Code Playgroud)
'notepad' |Stop-Process -Name {$_}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1722 次 |
最近记录: |