0
Get-Service | Stop-Process -Name WSearch -WhatIf
停止进程:输入对象不能被绑定到任何参数 命令或者因为该命令不采取管道输入或 输入和其属性不匹配 进行流水线输入的任何参数。在线:1 char:15 + Get-Service | Stop-Process -Name WSearch -WhatIf + ~~~~~~~~~~~~~~~~~~~~ + + + CategoryInfo:InvalidArgument: (FDPHOST:PSObject)[停止进程],ParameterBindingException + FullyQualifiedErrorId:InputObjectNotBound,Microsoft.PowerShell.Commands.StopProcessCommand的powershell得到服务管道以停止处理
现在,从我的理解,他们都共享相同的属性名称 “姓名”,所以我应该能够通过-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
所以我在这里做错了什么?
或者你可以做'Stop-Service -Name wsearch'。 –