gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 11:12:29 25 4
gpt4 key购买 nike

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

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

关于windows - Powershell get-service 通过管道传输到停止进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27733316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com