如何透過 PowerShell 根據啟動型別獲取服務?


以下命令可用於根據服務啟動型別(自動、手動或停用)篩選服務。

命令

獲取自動啟動服務。這些服務會在系統啟動時自動啟動。

Get-Service | where{$_.StartType -eq "Automatic"} | Select Name, Starttype

輸出

SystemEventsBroker          Automatic
TeraCopyService             Automatic
Themes                      Automatic
TrkWks                      Automatic
UserManager                 Automatic
UsoSvc                      Automatic
VMUSBArbService             Automatic
WavesSysSvc                 Automatic
Wcmsvc                      Automatic
Winmgmt                     Automatic
WlanSvc                     Automatic
WpnService                  Automatic
WpnUserService_158379       Automatic
wscsvc                      Automatic
WSearch                     Automatic
ZeroConfigService           Automatic

命令

獲取手動啟動服務。這些服務需要手動啟動,不會在系統啟動時自動啟動。它們可以由使用者或應用程式觸發啟動。

Get-Service | where{$_.StartType -eq "Manual"} | Select Name, Starttype

輸出

WinRM                                                     Manual
wisvc                                                     Manual
wlidsvc                                                   Manual
wlpasvc                                                   Manual
WManSvc                                                   Manual
wmiApSrv                                                  Manual
WMPNetworkSvc                                             Manual
workfolderssvc                                            Manual
WpcMonSvc                                                 Manual
WPDBusEnum                                                Manual

命令

獲取停用啟動服務。當這些型別的服務不再有用時,它們會被使用者或系統管理員停用。

Get-Service | where{$_.StartType -eq "Disabled"} | Select Name, Starttype

輸出

Name              StartType
----              ---------
AppVClient         Disabled
NetTcpPortSharing  Disabled
RemoteAccess       Disabled
RemoteRegistry     Disabled
shpamsvc           Disabled
ssh-agent          Disabled
svcdemo            Disabled
tzautoupdate       Disabled
UevAgentService    Disabled

更新於: 2020-01-22

3K+ 瀏覽次數

啟動你的職業

完成課程以獲得認證

開始
廣告
© . All rights reserved.