15.5. Using the get-service Cmdlet
The get-service cmdlet retrieves information about one or more services. In addition to the common parameters, the get-service cmdlet supports the following parameters (all the listed parameters are optional):
Name — Specifies the name(s) of the service(s) to be retrieved. Cannot be used with the DisplayName parameter.
Include — Specifies those items on which the cmdlet will act.
Exclude — Specifies those items on which the cmdlet will not act.
DisplayName — Specifies the display name(s) of the service(s). Cannot be used with the ServiceName parameter.
InputObject — The ServiceController object for the service(s) about which you want to retrieve information.
To retrieve information about all services installed on a system, simply type the following command without specifying any parameters:
get-service
You can focus the objects returned by specifying the -Name parameter with a suitable argument. You can use wildcards in the value of the -Name parameter. For example, to retrieve information about all services whose service name begins with m, use the command:
Get-Service -Name m*
To display those services sorted alphabetically and with their display name, use this command:
get-service -ServiceName m* | sort-object ServiceName | format-table Name,DisplayName -auto
Figure 15-22 shows the results of running the preceding command.
Figure 15.22. Figure 15-22
You can use the Status property of the objects returned from the get-service cmdlet together ...
Get Professional Windows® PowerShell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.