如何在PowerShell中基于多个条件参数获取服务?
要过滤出开始类型为“自动”和状态为“已停止”的服务,我们需要使用-AND比较运算符。在此,仅当两个条件都匹配时才显示服务。
命令
Get-Service | where{($_.StartType -eq "Automatic") -and ($_.Status -eq "Stopped")} |
Select Name, StartType, Status输出结果
Name StartType Status ---- --------- ------ gpsvc Automatic Stopped gupdate Automatic Stopped MapsBroker Automatic Stopped
命令
要使用开始类型为手动或禁用的服务来获取服务,我们将使用-OR运算符。
Get-Service | where{($_.StartType -eq "Manual") -or ($_.StartType -eq "Disabled")} |
Sort-Object Starttype | Select Name, StartType, Status输出结果
LxpSvc Manual Stopped lmhosts Manual Running KtmRm Manual Stopped IpxlatCfgSvc Manual Stopped FontCache3.0.0.0 Manual Running KeyIso Manual Running klvssbridge64_20.0 Manual Stopped UevAgentService Disabled Stopped tzautoupdate Disabled Stopped NetTcpPortSharing Disabled Stopped ssh-agent Disabled Stopped shpamsvc Disabled Stopped RemoteRegistry Disabled Stopped AppVClient Disabled Stopped svcdemo Disabled Stopped
热门推荐
10 读书祝福语女生短句简短
11 感谢同事新婚祝福语简短
12 感谢教官文案祝福语简短
13 员工聚会蛋糕祝福语简短
14 元宵发客户祝福语简短
15 给团队信心祝福语简短
16 医美的祝福语大全简短
17 异国姻缘的祝福语简短
18 兄妹拍照祝福语简短的话