How-to: List the background services [ServiceStatus.ps1]

List the services installed on one or more machines along with the status (running, stopped, disabled etc)
Call the script below passing the name of a text file containing the machines to query.
The output is written to a set of csv files in the current directory, one per machine: Services_<machine_name>.csv


function ServiceInfo{
    # Ping the machine to see if it is online
    $online=Test-Connection $mc -Quiet
    if ($online -eq $true)

    # List services and service status
    Get-CimInstance win32_service -computer $mc  | select displayname,name,startmode,`
       status,state |  sort-object -property displayName | `
          export-csv -path "Services_$mc.csv" -noTypeInformation
        Write-Verbose "     - Ping Failed!"
        Write-Host "Error: $mc not Pingable" -fore RED

## Main

if($file -and (test-Path $file))
    foreach($comp in (get-Content $file))
        Write-Host " +++ Processing Computer [$Comp] +++"
        ServiceInfo $comp


Call the script above passing the name of a text file containing the machines to query, one per line.
Assuming the script above is saved in the current directory as ServiceStatus.ps1

PS C:\> ./ServiceStatus workstations.txt

“In any collection of data, the figure most obviously correct, beyond all need of checking, is the mistake” ~ Finagle's third law

Related PowerShell Cmdlets

psinfo - List information about a system.
List of Windows 10 services with default status.
Get-Service - Get a list of services.

Copyright © 1999-2023
Some rights reserved