PS C:\Windows\system32> help Get-Service -Examples
名称
Get-Service
摘要
Gets the services on a localor remote computer.
Example 1: Get all services onthe computer
PS C:\>Get-Service
This command gets all ofthe services onthe computer. It behaves as though you typed `Get-Service *`. The default
display shows the status, service name, and display nameof each service.
Example 2: Get services thatbegin with a search string
PS C:\>Get-Service "wmi*"
This command retrieves services with service names thatbegin with WMI (the acronym for Windows Management Instrume
ntation).
Example 3: Display services that include a search string
PS C:\>Get-Service -Displayname "*network*"
This command displays services with a display namethat includes theword network. Searching the display name finds
network-related services even when the service namedoesnot include "Net", such as xmlprov, the Network Provision
ing Service.
Example 4: Get services thatbegin with a search stringand an exclusion
PS C:\>Get-Service -Name "win*" -Exclude "WinRM"
These commands get only the services with service names thatbegin with win, except forthe WinRM service.
Example 5: Display services that are currently active
PS C:\>Get-Service | Where-Object {$_.Status -eq "Running"}