确定powershell 2.0中的Service.StartType

Determine the Service.StartType in powershell 2.0

我们可以在 PowerShell 2.0 中获得 Service.StartType 吗?

Service.StartType 在 PowerShell 5.0 中有效,但在 PowerShell 2.0 中不产生结果。

$Service = Get-Service WinMgmt
$Service.StartType

我需要 PowerShell 2.0 中的 Service.StartType。有什么选择吗?

查询对应WMI class:

$winMgmtService = Get-WmiObject Win32_Service -Filter "Name = 'WinMgmt'"

# This will be either "Auto", "Manual", "Disabled" or "Unknown"
$winMgmtService.StartMode