Get-Service
Additional Resources for Get-Service |
Listing Service Information http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/get-service.mspx
|
SYNOPSIS
Gets the services on the local computer.
SYNTAX
Get-Service [[-name] <string[]>] [-include <string[]>] [-exclude <string[]>] [<CommonParameters>]
Get-Service -displayName <string[]> [-include <string[]>] [-exclude <string[]>] [<CommonParameters>]
Get-Service [-inputObject <ServiceController[]>] [-include <string[]>] [-exclude <string[]>] [<CommonParameters>]
DETAILED DESCRIPTION
The Get-Service cmdlet gets objects representing the services on the local 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 use the InputObject parameter to supply a service object representing each of the services that you want to retrieve.
PARAMETERS
-name <string[]>
Specifies the service names of services to be retrieved. Wildcards are permitted. By default, Get-Service gets all of the services on the computer.
Required? |
false |
Position? |
1 |
Default value |
* |
Accept pipeline input? |
true (ByValue, ByPropertyName) |
Accept wildcard characters? |
true |
-include <string[]>
Retrieves only the specified services. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as "s*". Wildcards are permitted.
Required? |
false |
Position? |
named |
Default value |
|
Accept pipeline input? |
false |
Accept wildcard characters? |
true |
-exclude <string[]>
Omits the specified services. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as "s*". Wildcards are permitted.
Required? |
false |
Position? |
named |
Default value |
|
Accept pipeline input? |
false |
Accept wildcard characters? |
true |
-displayName <string[]>
Specifies the display names of services to be retrieved. Wildcards are permitted. By default, Get-Service gets all services on the computer.
Required? |
true |
Position? |
named |
Default value |
|
Accept pipeline input? |
false |
Accept wildcard characters? |
true |
-inputObject <ServiceController[]>
Specifies the ServiceController objects to be retrieved. Enter a variable that contains the objects or type a command or expression that gets the objects.
Required? |
false |
Position? |
named |
Default value |
|
Accept pipeline input? |
true (ByValue) |
Accept wildcard characters? |
true |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. For more information, type, "get-help about_commonparameters".
INPUT TYPE
Object
RETURN TYPE
System.ServiceProcess.ServiceController
NOTES
For more information, type "Get-Help Get-Service -detailed". For technical information, type "Get-Help Get-Service -full".
Get-Service can display services only when the current user has permission to see them. If Get-Service does not display services, you might not have permission to see them.
To find the service name and display name of each service on your system, type "get-service". The service names appear in the "Name" column and the display names appear in the "DisplayName" column.
When specifying multiple values for a parameter, use commas to separate the values. For example, "<parameter-name> <value1>, <value2>".
You can also refer to Get-Service by its built-in alias, "gsv". For more information, see About_Alias.
EXAMPLE 1
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
get-service wmi*
This command retrieves services with service names that begin with "WMI".
EXAMPLE 3
get-service -displayname *network*
This command displays services with a display name that includes the word "network." This command lets you find network-related services even when the service name does not include "Net," such as xmlprov, the Network Provisioning Service.
EXAMPLE 4
$services = get-service
get-service -inputobject $Services -include RPC*
These commands display only the services with service names that begin with "RPC". The first command gets the services on the system and stores them in the $services variable. The second command gets the services in the $services variable, but includes only those that begin with "RPC". It uses the InputObject parameter to pass the objects stored in the variable to Get-Service.
EXAMPLE 5
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-Objectcmdlet, 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".
RELATED LINKS