Windows Tip Sheet
At Your Service
A quick tip on one of the more popular PowerShell cmdlets.
- By Jeffery Hicks
- 10/04/2006
One PowerShell cmdlet that is bound to be popular is Get-Service. When executed, a table is displayed in the console window showing the status of all services.
Get-Service
If we want to check the status of a particular service, we need to know its real name, not its display name:
Get-Service "browser"
This will display information about the Computer Browser service. The default formatting gives you basic information. If you want to see more try this:
Get-Service "browser" | format-list
Now you’ll get a list of the service’s name, display name, status, dependent services, services that that it depends on, and more. But what if you don’t know the service’s real name? Not to worry. We’ll pipe output to the Where cmdlet:
Get-Service | Where {$_.DisplayName -eq "computer browser"} |format-list
Let’s take this a step further. What if you’re not even sure of the service’s exact display name but you think it starts with Windows. We can use the -Like operator and do a wild card selection with the Where cmdlet:
Get-Service | Where {$_.DisplayName -like "windows*"}
Finally, to find only running or services, pipe the output of Get-Service to the Where cmdlet like this:
Get-Service | Where {$_.status -eq "running"}
Get-Service | Where {$_.status -eq "stopped"}
Using Get-Service can be must faster that using the Services management console once you get the hang of it. One downside is that it only manages the local system. To manage services on remote systems in PowerShell we need to use WMI. I’ll save that for another day.
[Editor's Note: This is the first column for Jeffery Hicks, who replaces Don Jones.]
About the Author
Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.