Problem
You want to see which services are running on the system.
Solution
To list all running services, use the GetService cmdlet: PS >GetService
Status
Name
DisplayName
Running
ADAM_Test
Test
Stopped
Alerter
Alerter
Running
ALG
Application Layer Gateway Service
Stopped
AppMgmt
Application Management
Stopped
aspnet_state
ASP.NET State Service
Running
AudioSrv
Windows Audio
Running
BITS
Background Intelligent Transfer Ser...
Running
Browser
Computer Browser
(...)
Discussion
The GetService cmdlet retrieves information about all services running on the system. Because these are rich .NET objects (of the type System.ServiceProcess. ServiceController), you can apply advanced filters and operations to make managing services straightforward.
For example, to find all running services:
PS >GetService | WhereObject { $_.Status eq "Running" }
Status Name DisplayName
Running ADAM_Test Test Running ALG Application Layer Gateway Service Running AudioSrv Windows Audio Running BITS Background Intelligent Transfer Ser... Running Browser Computer Browser Running COMSysApp COM+ System Application Running CryptSvc Cryptographic Services
Or, to sort services by the number of services that depend on them:
PS >GetService | SortObject Descending { $_.DependentServices.Count }
Status Name DisplayName
Running RpcSs Remote Procedure Call (RPC) Running PlugPlay Plug and Play Running lanmanworkstation Workstation Running SSDPSRV SSDP Discovery Service Running TapiSrv Telephony (...)
Since PowerShell returns fullfidelity .NET objects that represent system services, these tasks and more become incredibly simple due to the rich amount of information that PowerShell returns for each service. For more information about the GetService cmdlet, type GetHelp GetService.
The GetService cmdlet displays most (but not all) information about running services. For additional information (such as the service’s startup mode), use the GetWmiObject cmdlet:
$service = GetWmiObject Win32_Service | WhereObject { $_.Name eq "AudioSrv" } $service.StartMode