List Services With PowerShell

This article is also available on the Microsoft TechNet Wiki.

This article won a gold medal in The Microsoft TechNet Guru Awards! (December 2015).

Most people know you can see all the running services in a Windows operating system by employing services.msc through the Search box or Run command. From there, you can filter by Name or Startup Type to view what services are started, which are stopped, and which should have been started and perhaps failed.

You can also retrieve this information through PowerShell. The benefit of using PowertShell is that you can filter by Startup Type (startmode in PowerShell) or Status (state). For example, by using a PowerShell command you can find all services that have a Startup Type of Automatic and a Status of Stopped. This information is filtered and presented quickly to you. This saves you time from sorting and scrolling through the list of services.

Methodology

To find the services we are looking for, we will use the Get-WmiObject cmdlet within PowerShell. It is used to carry out system administration tasks and can even be run against remote computers. This cmdlet gets an instance of Windows Management Instrumentation (WMI) and any of its available sub-classes. We could also use its alias gwmi to shorten the cmdlet call.

Script To Find All Services

If you want to run a PowerShell command to find all services on your operating system, you can use a script similar to the one shown in the image below. It retrieves the Name, DisplayName, State, and StartMode of the services and then sorts them by State and Name. Setting the script up this way lets us see all of the Running and Stopped services grouped together. This provides a quick glimpse into services you suspect are causing a problem, especially if one is supposed to be Running and it is set to Stopped.

svc01

Script To Filter Services

If you need to be more precise in your searching, you can apply filters to your Get-WmiObject calls so that they return only the information you need. Using our example from above, to find all services that have a Startup Type of Automatic and a Status of Stopped we can apply a filter to return only services that meet this criteria.

svc02

Conclusion

In this article we saw how we can use the PowerShell Get-WmiObject cmdlet to find all the running services on an OS. We also saw how we can filter the data returned so it only shows the information we need to troubleshoot a problem. Using this filtering capability, we can see how much easier it is to quickly find services that meet our troubleshooting criteria.

References

Scripts

Download a copy of each PowerShell script from the TechNet Gallery:

They can also be found in my .

Related Articles

Advertisements

About Ken Cenerelli
I am a Programmer Writer, .NET Developer, Microsoft MVP - Visual Studio and Development Technologies, Public Speaker, Blogger, and Microsoft Azure Nerd. I blog regularly at kencenerelli.wordpress.com and can be found on Twitter via @KenCenerelli.

3 Responses to List Services With PowerShell

  1. Pingback: Microsoft Technical Guru – December 2015 | Ken Cenerelli

  2. awed1 says:

    Hi Ken,
    I am very unskilled at this stuff. I noticed that you have displayed the outcome, but that you haven’t included a text script to copy. I had to type it into notepad and then copy it to the PS (PowerShell). It was cumbersome that way. Thank you though because I was able to work through the instructions and finally bring up the short list.
    I do have a question.
    Maybe you know:
    Is it possible to have it grab the services and list them all, maybe in order the way that they appear in the GUI when I sort by Status, then from the PS screen add the filter directly to the printed output?
    Have it show the list of all services, then just filter from the results that are on the screen?
    Thanks in advance and thanks for your post, it helped me.
    B.

    • Thanks for your comment and question.

      Sorry you had to type the command out. The links at the bottom of the article point to the .ps1 script that when downloaded allow you to import them straight into PowerShell.

      To answer your question, it sounds like you want to manipulate the order of the returned items. To do so, you can play with the sort order of the query. For example, in the Get all services script I sort by State and then Name. This could be changed to:

      Sort StartMode -Descending (to see the startmode of all the services in reverse order)

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: