如何在 PowerShell 中根据启动类型获取服务?
powershellmicrosoft technologiessoftware & coding
以下命令可用于根据服务的启动类型(自动、手动或禁用)过滤服务。
命令
获取自动启动类型的服务。这些服务会在系统启动时自动启动。
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

