I'm trying to get a list of associated instances for a win32_service, and then separate those instances based on whether they "depend on" or are "required by" the win32_service.
For example, I can get a list of associations for the WAS service:
$service = Get-CimInstance -Query "SELECT * FROM win32_service WHERE name='WAS'"
Get-CimAssociatedInstance -InputObject $service -Association "win32_dependentservice"
This allows me to obtain a list of services associated to WAS; however, it doesn't state whether they are "antecedent" or "dependent" objects.
If I use WQL, I can see that the objects are enumerated by antecedent and dependent keys:
Get-CimInstance -Query "SELECT * FROM win32_dependentservice"
And, I can then specify the key when using "associators of"
Get-CimInstance -Query "Associators of {win32_service.name='WAS'} WHERE AssocClass=win32_dependentservice Role=dependent"
Is it possible to specify the "role" in Get-CimAssociatedInstance? Or, am I stuck with using WQL to determine if a service is dependent/antecedent?
EDIT: I specifically want to know if getting this information is possible with Cim cmdlets. I know Get-Service can get the information, but that is not what I am asking here.