Powershell Get-CimAssociatedInstance能否区分先行和依赖的win32\U服务?

Powershell Get-CimAssociatedInstance能否区分先行和依赖的win32\U服务?,powershell,wql,Powershell,Wql,我正在尝试获取win32_服务的关联实例列表,然后根据这些实例是“依赖”还是“需要”win32_服务来分隔它们 例如,我可以获得WAS服务的关联列表: $service = Get-CimInstance -Query "SELECT * FROM win32_service WHERE name='WAS'" Get-CimAssociatedInstance -InputObject $service -Association "win32_dependentservice" 这允许我获得

我正在尝试获取win32_服务的关联实例列表,然后根据这些实例是“依赖”还是“需要”win32_服务来分隔它们

例如,我可以获得WAS服务的关联列表:

$service = Get-CimInstance -Query "SELECT * FROM win32_service WHERE name='WAS'"
Get-CimAssociatedInstance -InputObject $service -Association "win32_dependentservice"
这允许我获得与WAS相关的服务列表;但是,它没有说明它们是“先行”对象还是“依赖”对象

如果我使用WQL,我可以看到对象由先行键和依赖键枚举:

Get-CimInstance -Query "SELECT * FROM win32_dependentservice"
然后,我可以在使用“的associators”时指定密钥

是否可以在Get-CimAssociatedInstance中指定“角色”?或者,我是否坚持使用WQL来确定服务是否依赖/先行


编辑:我特别想知道是否可以使用Cim cmdlet获取此信息。我知道Get服务可以获取信息,但这不是我在这里要问的。

我将把它作为一个答案。我认为最好的解决方案是使用Get-Service cmdlet。它向您提供您所请求的信息。使用和输出示例:

PS C:\windows\system32> Get-Service wwansvc|fl


Name                : wwansvc
DisplayName         : WWAN AutoConfig
Status              : Stopped
DependentServices   : {}
ServicesDependedOn  : {wcmsvc, RpcSs, NdisUio}
CanPauseAndContinue : False
CanShutdown         : False
CanStop             : False
ServiceType         : Win32ShareProcess

这表明没有任何东西依赖于它,但它依赖于wcmsvc、RpcSs和NdisUio。

有什么理由不使用Get服务吗?它显示DependentService和ServicesDependedOn。@我在这里没有提到它,但在我的情况下,我需要StartMode属性。Get服务没有此功能。我还想要一个win32_服务类型,而不是ServiceController类型。我希望这个问题得到正确的回答。
PS C:\windows\system32> Get-Service wwansvc|fl


Name                : wwansvc
DisplayName         : WWAN AutoConfig
Status              : Stopped
DependentServices   : {}
ServicesDependedOn  : {wcmsvc, RpcSs, NdisUio}
CanPauseAndContinue : False
CanShutdown         : False
CanStop             : False
ServiceType         : Win32ShareProcess