DataGen/get-componentTree.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
param ( $projectionname = "Microsoft.Windows.Computer.ProjectionType" )
function Get-Components
{
    param ( $object, $indent )
    if ( ! $object.__base.Parent -and $object.__base.Name)
    {
        write-host -for yellow $object.__base.Name
        new-object psobject -prop @{
            Indent              = ("-" * $indent * 2)
            Alias               = $object.DisplayName
            ComponentCollection = $object.ComponentCollection
            Parent              = $null
            Path                = $null
            TargetConstraint    = $object.TargetConstraint
            TargetEndpoint      = $object.TargetEndPoint
            TargetType          = $object.TargetType
            TypeProjection      = $object.TypeProjection
            ParentName          = $null
            Relationship        = $null
            Seed                = $null
            }
     }
    if( $object.Alias )
    {
        write-host -for cyan ("{0} {1}" -f ("-" * $indent*2),$object.Alias)
        new-object psobject -prop @{
            Indent              = ("-" * $indent * 2)
            Alias               = $object.Alias
            ComponentCollection = $object.ComponentCollection
            Parent              = $object.Parent
            Path                = $object.Path
            TargetConstraint    = $object.TargetConstraint
            TargetEndpoint      = $object.TargetEndPoint
            TargetType          = $object.TargetType
            TypeProjection      = $object.TypeProjection
            ParentName          = $object.ParentName
            Relationship        = $object.Relationship
            Seed                = $object.Seed
            }
    }
    if ( $object.ComponentCollection.Count -gt 0 )
    {
        foreach($o in $object.ComponentCollection )
        {
            Get-Components $o ($indent+1)
        }
    }
}

$p = get-scsmtypeprojection $projectionname
Get-Components $p 0
$p.__base.CreateNavigator().outerxml|write-host