The Get-Service cmdlet is used for retrieving the services installed on the local computer and the remote computers as well along with their Start type, status, name and display name of the services.

By default Get-Service returns information about local computer services unless the –ComputerName parameter is specified for the remote computers.

It is also possible to retrieve the dependent services.

Syntax

Get-Service
[[-Name] <String[]>] [[-DisplayName] <String[]>
[-DependentServices] [-RequiredServices] [-Include <String[]>] [-Exclude <String[]>] [-InputObject <ServiceController[]>] []

Parameters

-DependentServices

Indicates that this cmdlet gets only the services that depend upon the specified service.

-DisplayName

Specifies, as a string array, the display names of services to be retrieved. Wildcards are permitted.

-Exclude

Specifies, as a string array, a service or services that this cmdlet excludes from the operation. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as s*. Wildcards are permitted.

-Include

Specifies, as a string array, a service or services that this cmdlet includes in the operation. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as s*. Wildcards are permitted.

-InputObject

Specifies ServiceController objects representing the services to be retrieved. Enter a variable that contains the objects, or type a command or expression that gets the objects. You can pipe a service object to this cmdlet.

-Name

Specifies the service names of services to be retrieved. Wildcards are permitted.

-RequiredServices

Get only the services that this service requires.

Indicates that this cmdlet gets only the services that this service requires. This parameter gets the value of the ServicesDependedOn property of the service.

 

Examples

This example gets all of the services on the computer.

The default display shows the status, service name, and display name of each service.

Get-Service

 

This example retrieves services with service names that begin with wua.

Get-Service “wua*”

Which displayed the following

Status   Name               DisplayName
------   ----               -----------
Stopped  wuauserv           Windows Update

 

You can get a list of services like this

Get-Service -Name DPS, VSS, Spooler

 

This example displays only the services with a status of Running.

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

 

To get the depended services information of the particular service, use the below command.

Get-Service “WinRM” -RequiredServices

You should see something like this

Status   Name               DisplayName
------   ----               -----------
Running  RPCSS              Remote Procedure Call (RPC)
Running  HTTP               HTTP Service

With the exclude parameter, service names are excluded and the rest of the services will be displayed.

This will exclude services beginning with A, B and including vmi

Get-Service -Exclude A*, B*, *vmi*

 

You can display all the properties for a service using Format-List

Get-Service Winmgmt | Format-List *

This displayed the following

Name                : Winmgmt
RequiredServices    : {RPCSS}
CanPauseAndContinue : True
CanShutdown         : True
CanStop             : True
DisplayName         : Windows Management Instrumentation
DependentServices   : {MBAMService, NcaSvc, iphlpsvc}
MachineName         : .
ServiceName         : Winmgmt
ServicesDependedOn  : {RPCSS}
ServiceHandle       :
Status              : Running
ServiceType         : Win32OwnProcess, Win32ShareProcess
StartType           : Automatic
Site                :
Container           :