Last active
September 16, 2017 06:27
-
-
Save mattifestation/a39ae342f8b41664720f to your computer and use it in GitHub Desktop.
Enumerates all association classes and the classes they link for a given WMI namespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-AssociatedClassRelationship { | |
param ( | |
[String] | |
$Namespace = 'root/cimv2' | |
) | |
Get-CimClass -Namespace $Namespace | ? { $_.CimClassQualifiers['Association'] -and (-not $_.CimClassQualifiers['Abstract']) } | % { | |
$KeyQualifiers = @($_.CimClassProperties | ? { $_.Qualifiers['key'] }) | |
if ($KeyQualifiers.Count -eq 2) { | |
$Properties = [Ordered] @{ | |
AssociationClassName = $_.CimClassName | |
LinkedClassName1 = $KeyQualifiers[0].ReferenceClassName | |
LinkedClassName2 = $KeyQualifiers[1].ReferenceClassName | |
} | |
New-Object PSObject -Property $Properties | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment