Powershell - export list of all running services


I have recently started using powershell to create scripts to automate mundane tasks. Within this guide, I will explain what commands you need to see running services on your machine & how to export them to a csv file.

 

Firstly,  you will need to open Powershell.

 

We will use the get-service command.

 

Type:

get-service 

and hit return.  This will return a list of all services running on your machine.

 

To filter this down to just 'running' services.  We would type:

 

get-service | 
where-Object Status -eq 'running'

 

If you would like to change the columns returned you can use the select-object command:

get-service | 
where-Object Status -eq 'running' |
select-object DisplayName, Status

If we want to export these results into a csv file, first we need to set a location (to save the file) then use the export-csv command

set-location -path c:\exports
get-service | 
where-Object Status -eq 'running' |
select-object DisplayName, Status |
export-csv .\running-services.csv

If your scripts are very long, you could always assign it to a variable and export it later e.g.

$services = get-service | 
where-Object Status -eq 'running' |
select-object DisplayName, Status

$services | export-csv .\running-services.csv

Comment