[英]Powershell get-service piped to stop-process
Get-Service | Stop-Process -Name WSearch -WhatIf
Stop-Process:輸入對象不能綁定到該命令的任何參數,因為該命令不接受管道輸入,或者該輸入及其屬性與接受管道輸入的任何參數都不匹配。 在第1行:15個字符+ Get-Service | Stop-Process -Name WSearch -WhatIf + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:InvalidArgument:(fdPHost :PSObject)[Stop-Process],ParameterBindingException + FullyQualifiedErrorId:InputObjectNotBound,Microsoft.PowerShell.Commands.StopProcessCommand
現在,根據我的理解,它們都共享相同的屬性名稱“名稱”,因此我應該能夠通過-名稱進行傳遞,對嗎?
PS C:\> Get-Service | gm
TypeName: System.ServiceProcess.ServiceController
Name MemberType Definition
---- ---------- ----------
Name AliasProperty Name = ServiceName
get-help stop-process
-Name <String[]>
Specifies the process names of the processes to be stopped. You can type multiple process names (separated by commas) or use wildcard characters.
Required? true
Position? named
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? true
那我在這做錯了嗎?
Get-Service -Name wsearch | Stop-Service
將工作。 首先過濾,然后將結果通過管道。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.