Powershell get-service 通过管道传输到停止进程

Powershell get-service piped to stop-process

Get-Service | Stop-Process -Name WSearch -WhatIf

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:15 + Get-Service | Stop-Process -Name WSearch -WhatIf + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (fdPHost:PSObject) [Stop-Process], ParameterBindingException + FullyQualifiedErrorId : InputObjectNotBound,Microsoft.PowerShell.Commands.StopProcessCommand

现在根据我的理解,它们共享相同的属性名称 "Name" 所以我应该能够通过 -Name 进行管道传递,对吗?

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

会起作用。先过滤,然后通过管道传递结果。