Check Remote Services with Powershell

By | 2014-08-02

If you need to check the status of a service across several machines, and don’t have monitoring in place, you can use PowerShell to get Running/Stopped/Starting status quickly.

This one-liner should be of assistance.  I’ll pick it apart below.

Get-Service -ComputerName Computer001,Computer002,Computer003,Computer004,Computer005 | Select Name,Status,Machinename | Sort Machinename | Format-Table -autosize

Get-Service
This might come as a surprise: the Get-Service cmdlet is designed to retrieve information about the services installed on your computer or remote computers.  And folks say PowerShell is complicated.


The name of the service that you want status for.  This field also accepts wildcard info.  For example, if you want to see the status of the print spooler, any of these would work:

*spool*
print*
*spooler

-ComputerName
This is the name or names of the remote machines that you want to query for status.  If you enter multiple names, be sure to seperate each by a comma.  Leaving this parameter out will get information from the local machine.

Select name,status,machinename
A pipeline to the select function shows us only the fields we are interested in, the name of the service, current status, and what machine we are querying.

Sort Machinename
Pretty self explanatory, this sorts the output by the name of the remote machine, based on the list given.

Format-Table -autosize
Throw the output in a table, sizing columns automatically.

Run against a text file

You can modify this slightly to read a list of computer names from a file.  That way, you just modify the text file, which contains a list of computer names with one per line, whenever you want to run a check against more machines.

Get-Service -computername (get-content c:\MyDirectory\MyServers.txt) | Select name,status,machinename |sort name | format-table -autosize

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.