如何使用 PowerShell 透過 WMI 方法獲取服務資訊?


你也可以使用 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

更新於: 2020 年 1 月 22 日

超過 2K 的瀏覽量

開啟您的職業生涯

完成課程並獲得認證

開始
廣告
© . All rights reserved.