您也可以使用WMI方法代替标准命令Get-Service来获取服务信息。
命令
要在服务器上获取服务信息,您需要使用WMI类Win32_Service。Get-WmiObject -Class Win32_Service
输出结果ExitCode : 0
Name : Browser
ProcessId : 0
StartMode : Manual
State : Stopped
Status : OK
ExitCode : 0
Name : BTAGService
ProcessId : 1468
StartMode : Manual
State : Running
Status : OK
ExitCode : 0
Name : BthAvctpSvc
ProcessId : 1460
StartMode : Manual
State : Running
Status : OK
ExitCode : 0
Name : bthserv
ProcessId : 1480
StartMode : Manual
State : Running
Status : OK
命令
您可以使用Select-Object过滤特定的输出。Get-WmiObject win32_Service | Select-Object Name, State, Startmode
输出结果Name State Startmode
---- ----- ---------
AdobeARMservice Running Auto
AdobeFlashPlayerUpdateSvc Stopped Manual
AJRouter Stopped Manual
ALG Stopped Manual
AppIDSvc Stopped Manual
Appinfo Running Manual
AppMgmt Stopped Manual
AppReadiness Stopped Manual
AppVClient Stopped Disabled
AppXSvc Stopped Manual
AssignedAccessManagerSvc Stopped Manual
AudioEndpointBuilder Running Auto
Audiosrv Running Auto
autotimesvc Stopped Manual
AVP20.0 Running Auto
AxInstSV Stopped Manual
BDESVC Stopped Manual
BFE Running Auto
BITS Running Auto
Bluetooth Device Monitor Running Auto
Bluetooth OBEX Service Running Auto
使用WMI在远程计算机上获取服务。Get-WmiObject win32_Service –ComputerName Win7,Test-PC | Select-
Object Name, State, Startmode