As you most likely already know, in Windows operating systems, a Windows service is a computer program that operates in the background, just like daemons in a Unix-like environment. They can be configured to either start when the operating system is started and run in the background as long as Windows is running, or started manually using the Service Manager tool, which can be launched by typing services.msc from the command prompt or by opening the start menu, typing "services" from the Start Menu and then launching the Service Manager icon that should show up right away.
In this post we'll see some useful command-line prompt (CMD) and Powershell commands that can be used from most Windows environments (including Windows 10 and Windows Server) to list the installed / active / inactive services, as well as search for a specific service in Windows.
Command-Line (CMD) commands
How to list all Windows services:
1 |
sc queryex type=service state=all |
How to list all Windows services (names only):
1 |
sc queryex type=service state=all | find /i "SERVICE_NAME:" |
How to list all the running Windows services, excluding the stopped / inactive ones:
1 |
sc queryex type=service state=active |
How to list all the stopped / inactive Windows services, excluding the running ones:
1 |
sc queryex type=service state=inactive |
How to search for a given Windows service (by name):
1 |
sc queryex type=service state=all | find /i "SERVICE_NAME: MyServiceName" |
How to retrieve the status of a given service (by name):
1 |
sc query MyServiceName |
PowerShell commands
How to list all Windows services:
1 |
Get-Service |
How to list all Windows services (names only):
1 |
sc queryex type=service state=all | find /i "SERVICE_NAME:" |
How to list all the running Windows services, excluding the stopped / inactive ones:
1 |
Get-Service | Where-Object {$_.Status -eq "Running"} |
How to list all the stopped / inactive Windows services, excluding the running ones:
1 |
Get-Service | Where-Object {$_.Status -eq "Stopped"} |
How to search for a specific Windows service:
1 |
Get-Service | Where-Object {$_.Name -like "*MyServiceName*"} |
How to retrieve the status of a given service (by name):
1 |
Get-Service MyServiceName* |
Conclusions
We definitely hope that this post will help those system administrators that are looking for a quick and effective way to list, filter, search and/or retrieve the status of the Windows Services installed on their Windows machines using the command-line prompt (CMD) or Powershell.
I need to find a Windows service on our network where I don’t know the host name of the server/pc the service is installed on. The service is only installed on one computer.
hmmm sc has a state parameter?