106
106
Where-Object { -not $excludeProperty -or $excludeProperty -notcontains $_ }
107
107
}
108
108
} # Get-PropertyOrder
109
+
110
+ $Output = @ {}
109
111
}
110
112
111
113
Process {
118
120
119
121
# loop through every property in this one object
120
122
foreach ($prop in $props ){
121
-
122
- # set up a variable name we will use to store an array of unique types for this property
123
- $varName = " _My$prop "
124
-
123
+
125
124
# try to get the property type. If it's null, say so
126
125
Try {
127
126
$type = $obj .$prop.gettype ().FullName
130
129
$type = $null
131
130
}
132
131
133
- # init currentvalue to null, might not need this
134
- $currentValue = $null
135
-
136
- # check to see if we already have an array of types for this property. Set current value in the logic
137
- if (-not ($currentValue = Get-Variable $varName - ErrorAction SilentlyContinue - ValueOnly)){
132
+ # check to see if we already have types for this prop
133
+ if (-not $Output.ContainsKey ($prop )){
138
134
139
- # we don't have an array yet. Start one, put the type in it, give it a description we can use later
135
+ # we don't have an array yet. Start one, put the type in it
140
136
$List = New-Object System.Collections.ArrayList
141
137
[void ]$List.Add ($type )
142
- Set-Variable - name $varName - value $List - force - Description " _MyProp "
138
+ $Output .Add ( $prop , $List )
143
139
144
140
}
145
141
else {
146
- if ($currentValue -notcontains $type ){
142
+ if ($Output [ $prop ] -notcontains $type ){
147
143
148
144
# type isn't in the array yet, add it
149
- [void ]$currentValue.Add ($type )
150
- Set-Variable - name $varName - Value $currentValue - force - Description " _MyProp"
145
+ [void ]$output [$prop ].Add($type )
151
146
}
152
147
}
153
148
}
154
149
}
155
150
}
156
151
End {
157
-
158
- # get all the results, remove _My from their name
159
- Get-Variable - Scope 0 |
160
- Where-Object {$_.Description -eq " _MyProp" } |
161
- Select-Object - Property @ { label = " Name" ; expression = {$_.name -replace " ^_My" , " " } }, Value
162
-
152
+
153
+ $Output
163
154
}
164
155
}
0 commit comments