How to Get Windows Services Using PowerShell?

In this tutorial, I will explain how to get Windows services using PowerShell from your computer. I will show you how to use the Get-Service cmdlet in PowerShell with various parameters.

Get-Service PowerShell Cmdlet

PowerShell provides a built-in cmdlet called Get-Service that allows you to retrieve information about Windows services. With this cmdlet, you can list all services, filter services based on specific criteria, and view detailed properties of individual services. The Get-Service cmdlet is part of the Microsoft.PowerShell.Management module, which is available by default in PowerShell.

Check out Get Windows Activation Status Using PowerShell

Get All Windows Services Using PowerShell

To get a list of all services on your computer, you can simply run the Get-Service cmdlet without any parameters. Here’s an example:

Get-Service

This command will display a table with the following columns:

  • Status: The current state of the service (Running, Stopped, etc.)
  • Name: The name of the service
  • DisplayName: The friendly name of the service

You can see in the screenshot below that it gave me all the services in PowerShell.

Get All Windows Services Using PowerShell

Read How to List Drives in PowerShell?

Filter Various Windows Services

In many cases, you may want to filter the list of services based on specific criteria. The Get-Service cmdlet provides several parameters to help you narrow down the results.

Filtering by Name

To filter services by name, you can use the -Name parameter followed by the service name or a wildcard pattern. For example, to retrieve services whose names start with “Win,” you can use the following command:

Get-Service -Name "Win*"

This command will return services like “WinRM,” “WinDefend,” and “WinHttpAutoProxySvc.”

Here is the exact output in the screenshot below:

Filter Various Windows Services

Filtering by Status

You can also filter services based on their current status using the -Status parameter. For example, to retrieve only the running services, use the following command:

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

Similarly, you can filter stopped services by specifying -Status Stopped.

Here is the exact output in the screenshot below:

How to Get Windows Services Using PowerShell

View Windows Service Properties

In addition to the basic information displayed by default, the Get-Service cmdlet allows you to access detailed properties of services. You can pipe the output of Get-Service to the Select-Object cmdlet to specify the desired properties.

For example, to view the display name, status, and start type of services, you can use the following command:

Get-Service | Select-Object DisplayName, Status, StartType

This command will display a table with the specified properties for all services.

Check out How to List Printers Using PowerShell?

Export Windows Service Information Text or CSV File

Sometimes, you may need to export the list of services and their details to a file for further analysis or documentation purposes. PowerShell makes it easy to export service information to various file formats.

Exporting to a Text File

To export the list of services to a text file, you can use the Out-File cmdlet. Here’s an example:

Get-Service | Out-File -FilePath "C:\Services.txt"

This command will export the list of services to a file named “Services.txt” in the “C:\” directory.

Exporting to a CSV File

For more structured data, you can export the service information to a CSV (Comma-Separated Values) file using the Export-Csv cmdlet. Here’s an example:

Get-Service | Select-Object DisplayName, Status, StartType | Export-Csv -Path "C:\Services.csv" -NoTypeInformation

This command will export the display name, status, and start type of services to a CSV file named “Services.csv” in the “C:\” directory.

Read Get a List of Installed Programs Using PowerShell

Example of PowerShell Get-Service Cmdlet

Let’s consider a real-world scenario where you need to troubleshoot an issue with a specific service on a server in the United States. For example, suppose the “Print Spooler” service is not running correctly, causing printing issues for users in the an office.

To investigate the problem, you can use the Get-Service cmdlet to retrieve information about the “Print Spooler” service:

Get-Service -Name "Spooler" | Select-Object DisplayName, Status, StartType, DependentServices

This command will display the display name, status, start type, and dependent services of the “Print Spooler” service. By examining this information, you can determine if the service is running, if it’s set to start automatically, and if any dependent services are affecting its functionality.

Based on the output, you can take appropriate actions, such as starting the service if it’s stopped, modifying its start type, or investigating dependent services for potential issues.

Conclusion

In this tutorial, I have explained how to get Windows services using the PowerShell Get-Service cmdlet. Also, we can filter the services based on specific parameters. I hope all these examples will be helpful.

You may also like:

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.