Get-Service cmdlet | PowerShell
Tags: powershell, getservice, script, services
Published: 2022-01-04 19:16:27

---
title: Get-Service cmdlet | PowerShell
published: true
date: 2021-12-06 17:04:48 UTC
tags: Powershell,GetService,Script,Services
canonical_url: 
---

 **Version:**  5.1.x

Let’s explore a little bit the **[Get-Service](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-service?view=powershell-7.2)** PowerShell cmdlet. Recently I needed to look for specific windows services and check their status. In this post, I’ll try to share this experience and easily show a way to monitor and get this information.

During this post, I’ll be doing my examples on Visual Studio Code with an extension to interpret PowerShell scripts. I like to use this editor, but feel free to attempt on Windows ISE, the only thing that you’ll need to take care of is to run one or the other as administrator to avoid permission issues.

Let’s see how the cmdlet works and what we can do with it… Firstly, just run it alone without adding any parameters and see what you get.

```powershell
#getting all the services from the machine you're running the script
Get-Service
```

Even if the sort is made by a different column you can easily verify that the result is the one that you’re expecting by executing the services from windows.

![](https://toolgbrmaker.files.wordpress.com/2021/12/image-11.png?w=1024)

You already know what we can get from the cmdlet but now how can you refine your results? Let’s attempt to get some extra info from the helper.

![](https://toolgbrmaker.files.wordpress.com/2021/12/image-12.png?w=1024)

As we can realize from our helper query, the cmdlet allows us to send some parameters to refine our results. Besides that, and this may be very helpful, you can also get the result not only from your Local Computer but also from a Remote Computer.

Our example will pass only throw executing the script targeting a Local Computer but we’ll also add on it the – **ComputerName** just for testing purposes.

A new attempt to refine our results.

```powershell
#Filtering the services - refining the results
Get-Service -ComputerName 'PTPOPF247203' -DisplayName '*Hyper-V*'
```

What we’ll get now are all the services that have on its – **DisplayName** the “Hyper-V” word.

![](https://toolgbrmaker.files.wordpress.com/2021/12/image-13.png?w=1024)

Now you are seeing the target you aimed, but well, imagine that this task was asked by someone that is not interested in the ugly name that the services have… How we can display only the columns that we want!? The next code will help.

```powershell
#Filtering the services - refining the results
Get-Service -ComputerName 'PTPOPF247203' -DisplayName '*Hyper-V*' |
Select DisplayName,Status
```

And the result is…

![](https://toolgbrmaker.files.wordpress.com/2021/12/image-14.png?w=1024)

Now looks much more interesting… As you see with some refining and using the **[Select PowerShell cmdlet](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/select-object?view=powershell-7.2)** we were able to query some useful data from our local machine.

Because nothing else can get you faster on the track… Do it by yourself on your Local or Remote Machine and let us know the results.