
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get Services Based on Multiple Conditional Parameters in PowerShell
To filter out services with both start-type “Automatic” and Status “stopped” we need to use the -AND comparison operator. Here, services will be displayed only when both conditions are matching.
Command
Get-Service | where{($_.StartType -eq "Automatic") -and ($_.Status -eq "Stopped")} | Select Name, StartType, Status
Output
Name StartType Status ---- --------- ------ gpsvc Automatic Stopped gupdate Automatic Stopped MapsBroker Automatic Stopped
Command
To get services with start-type manual or disabled we will use -OR operator.
Get-Service | where{($_.StartType -eq "Manual") -or ($_.StartType -eq "Disabled")} | Sort-Object Starttype | Select Name, StartType, Status
Output
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
Advertisements