[英]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.