Powershell

How to Use the “Get-Service” Command in PowerShell

The cmdlet “Get-Service” in PowerShell gets or retrieves the information about the services on the computer. These services include both stopped and running. Moreover, to get all the available services, the stated command can be used without parameters and also get a customized set of services by using a specified list of parameters.

This post will elaborate on the PowerShell “Get-Service” cmdlet.

How to Utilize/Use the “Get-Service” Command in PowerShell?

As stated above, the “Get-Service” cmdlet is utilized to get the available services in PowerShell including running and stopped ones.

Let’s move to the following examples for getting all services by executing the above-stated cmdlet.

Example 1: Use the “Get-Service” Cmdlet to Get all Services on the Computer
To retrieve all the services of the computer, execute the below-provided cmdlet:

Get-Service

Example 2: Use the “Get-Service” Cmdlet to Display Services That Include a Specified Search String

This example will display all t

To display all the services that include a particular search string that specified by the user, execute the “Get-Services” command along with the required parameter:

Get-Service -Displayname "*update*"

According to the above code:

  • First, enter the “Get-Service” cmdlet, followed by the “-Displayname” parameter having the “*update*” value assigned.
  • The string is enclosed within two wildcards so that it can be matched with the exact similar keyword from a search result:

Example 3: Use the “Get-Service” Cmdlet to Get Services That Begin with a Search String
To get the particular services that begin with the specified search string, use the “Get-Service ” cmdlet having a specific value assigned to it with the wildcard at the end. Putting an asterisk at the end of the string will help in finding the string that starts with the specific keyword:

Get-Service "xbox*"

Example 4: Use the “Get-Service” Cmdlet to Get Services That Begin with a Search String and an Exclusion
The below-stated command will search specific string and it will add an exclusion:

Get-Service -Name "xbox*" -Exclude "XboxNetApiSvc"

In the above-stated code:

  • Enter the “Get-Service” cmdlet along with the “-Name” parameter having the “xbox*” value assigned to it.
  • After that, specify the “-Exclude” parameter and assign the stated value to exclude it from the output:

Example 5: Use the “Get-Service” Cmdlet to Display Services That are Currently Active
To get and view all currently active services, use the provided command:

Get-Service | Where-Object {$_.Status -eq "Stopped"}

In the above-provided command:

  • Specify the “Get-Service” cmdlet followed by the pipeline “|”.
  • After that, add the “Where-Object” cmdlet and then specify the condition to get only the active services:

That’s all! We have provided the working of the “Get-Service” cmdlet in PowerShell.

Conclusion

In PowerShell, the “Get-Service” cmdlet is used for getting the list of the services operating on Windows. It gets the list of both running and stopped services. Moreover, it uses the parameters to get a personalized set of services. This post has explained the “Get-Service” cmdlet in detail.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.