PowerShell Logo Small

Get-Service



This is the built-in help made by Microsoft for the command 'Get-Service', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Gets the services on a local or remote computer.

SYNTAX


Get-Service [[-Name] [<String[]>]] [-ComputerName [<String[]>]] [-DependentServices] [-Exclude [<String[]>]] [-Include [<String[]>]] [-InformationAction {SilentlyContinue |
Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String]>]] [-RequiredServices] [<CommonParameters>]
Get-Service [-ComputerName [<String[]>]] [-DependentServices] [-Exclude [<String[]>]] [-Include [<String[]>]] [-InformationAction {SilentlyContinue | Stop | Continue |
Inquire | Ignore | Suspend}] [-InformationVariable [<System.String]>]] [-RequiredServices] -DisplayName <String[]> [<CommonParameters>]
Get-Service [-ComputerName [<String[]>]] [-DependentServices] [-Exclude [<String[]>]] [-Include [<String[]>]] [-InformationAction {SilentlyContinue | Stop | Continue |
Inquire | Ignore | Suspend}] [-InformationVariable [<System.String]>]] [-InputObject [<ServiceController[]>]] [-RequiredServices] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Get-Service cmdlet gets objects that represent the services on a local computer or on a remote computer, including running and stopped services.


You can direct Get-Service to get only particular services by specifying the service name or display name of the services, or you can pipe service objects to Get-Service.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=290503
New-Service
Restart-Service
Resume-Service
Set-Service
Start-Service
Stop-Service
Suspend-Service

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

PS C:\>get-service



This command retrieves all of the services on the system. It behaves as though you typed "get-service *". The default display shows the status, service name, and display
name of each service.










-------------------------- EXAMPLE 2 --------------------------

PS C:\>get-service wmi*



This command retrieves services with service names that begin with "WMI" (the acronym for Windows Management Instrumentation).










-------------------------- EXAMPLE 3 --------------------------

PS C:\>get-service -displayname *network*



This command displays services with a display name that includes the word "network". Searching the display name finds network-related services even when the service name
does not include "Net", such as xmlprov, the Network Provisioning Service.










-------------------------- EXAMPLE 4 --------------------------

PS C:\>get-service -name win* -exclude winrm



These commands get only the services with service names that begin with "win", except for the WinRM service.










-------------------------- EXAMPLE 5 --------------------------

PS C:\>get-service | where-object {$_.Status -eq "Running"}



This command displays only the services that are currently running. It uses the Get-Service cmdlet to get all of the services on the computer. The pipeline operator (|)
passes the results to the Where-Object cmdlet, which selects only the services with a Status property that equals "Running".

Status is only one property of service objects. To see all of the properties, type "get-service | get-member".










-------------------------- EXAMPLE 6 --------------------------

PS C:\>get-service -computername Server02



This command gets the services on the Server02 remote computer.

Because the ComputerName parameter of Get-Service does not use Windows PowerShell remoting, you can use this parameter even if the computer is not configured for remoting in
Windows PowerShell.










-------------------------- EXAMPLE 7 --------------------------

PS C:\>get-service | where-object {$_.DependentServices} | format-list -property Name, DependentServices, @{Label="NoOfDependentServices";
Expression={$_.dependentservices.count}}

Name : AudioEndpointBuilder
DependentServices : {AudioSrv}
NoOfDependentServices : 1
Name : Dhcp
DependentServices : {WinHttpAutoProxySvc}
NoOfDependentServices : 1
...



These commands list the services on the computer that have dependent services.

The first command uses the Get-Service cmdlet to get the services on the computer. A pipeline operator (|) sends the services to the Where-Object cmdlet, which selects the
services whose DependentServices property is not null.

Another pipeline operator sends the results to the Format-List cmdlet. The command uses its Property parameter to display the name of the service, the name of the dependent
services, and a calculated property that displays the number of dependent services that each service has.










-------------------------- EXAMPLE 8 --------------------------

PS C:\>get-service s* | sort-object status

Status Name DisplayName
------ ---- -----------
Stopped stisvc Windows Image Acquisition (WIA)
Stopped SwPrv MS Software Shadow Copy Provider
Stopped SysmonLog Performance Logs and Alerts
Running Spooler Print Spooler
Running srservice System Restore Service
Running SSDPSRV SSDP Discovery Service
Running ShellHWDetection Shell Hardware Detection
Running Schedule Task Scheduler
Running SCardSvr Smart Card
Running SamSs Security Accounts Manager
Running SharedAccess Windows Firewall/Internet Connectio...
Running SENS System Event Notification
Running seclogon Secondary Logon

PS C:\>get-service s* | sort-object status -descending

Status Name DisplayName
------ ---- -----------
Running ShellHWDetection Shell Hardware Detection
Running SharedAccess Windows Firewall/Internet Connectio...
Running Spooler Print Spooler
Running SSDPSRV SSDP Discovery Service
Running srservice System Restore Service
Running SCardSvr Smart Card
Running SamSs Security Accounts Manager
Running Schedule Task Scheduler
Running SENS System Event Notification
Running seclogon Secondary Logon
Stopped SysmonLog Performance Logs and Alerts
Stopped SwPrv MS Software Shadow Copy Provider
Stopped stisvc Windows Image Acquisition (WIA)



This command shows that when you sort services in ascending order by the value of their Status property, stopped services appear before running services. This happens
because the value of Status is an enumeration, in which "Stopped" has a value of "1", and "Running" has a value of 4.

To list running services first, use the Descending parameter of the Sort-Object cmdlet.










-------------------------- EXAMPLE 9 --------------------------

PS C:\>get-service -name winrm -computername localhost, Server01, Server02 | format-table -property MachineName, Status, Name, DisplayName -auto

MachineName Status Name DisplayName
------------ ------ ---- -----------
localhost Running WinRM Windows Remote Management (WS-Management)
Server01 Running WinRM Windows Remote Management (WS-Management)
Server02 Running WinRM Windows Remote Management (WS-Management)



This command uses the Get-Service cmdlet to run a "Get-Service Winrm" command on two remote computers and the local computer ("localhost").

The Get-Service command runs on the remote computers, and the results are returned to the local computer. A pipeline operator (|) sends the results to the Format-Table
cmdlet, which formats the services as a table. The Format-Table command uses the Property parameter to specify the properties displayed in the table, including the
MachineName property.










-------------------------- EXAMPLE 10 --------------------------

PS C:\>get-service winrm -requiredServices



This command gets the services that the WinRM service requires.

The command returns the value of the ServicesDependedOn property of the service.










-------------------------- EXAMPLE 11 --------------------------

PS C:\>"winrm" | get-service



This command gets the WinRM service on the local computer. This example shows that you can pipe a service name string (enclosed in quotation marks) to Get-Service.