如何在PowerShell中停止其相关服务的服务?
要停止在PowerShell中具有相关服务的服务,请使用-Force参数。首先,我们将检查特定服务的依赖服务是什么,以获取它们-DependentService参数。
示例
例如,WMI服务(名称:Winmgmt)具有多个从属服务。
Get-Service -Name Winmgmt -DependentServices
输出结果
tatus Name DisplayName ------ ---- ----------- Running UALSVC User Access Logging Service Stopped smstsmgr ConfigMgr Task Sequence Agent Stopped SepLpsService Symantec Endpoint Protection Local ... Stopped NcaSvc Network Connectivity Assistant Running iphlpsvc IP Helper Running CcmExec SMS Agent Host
现在,我们将使用-Force参数停止WinmgmtService及其相关服务。要检查命令,请添加-verbose参数。
Stop-Service -Name Winmgmt -Force -Verbose
使用显示名称,
Stop-Service -DisplayName "Windows Management Instrument" -Force -Verbose
停止相关服务的另一种方法是先获取相关服务,然后获取管道Stop-Service参数,并且这次无需使用-Force参数,但这只会停止相关服务,而不是指定的服务。
Get-Service Winmgmt -DependentServices | Stop-Service -Verbose
上面的命令将停止Winmgmt的相关服务,但不会停止本身。
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短