【发布时间】:2015-02-28 06:18:39
【问题描述】:
Get-Service | Stop-Process -Name WSearch -WhatIf
Stop-Process : 输入对象不能绑定到任何参数 该命令要么是因为该命令不接受管道输入,要么 输入及其属性不匹配任何参数 接受管道输入。在行:1 字符:15 + 获取服务 |停止进程 -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
所以我在这里做错了吗?
【问题讨论】:
标签: windows powershell