@@ -29,10 +29,10 @@ function Read-Snapshot {
2929}
3030
3131function To-StringSet {
32- param ([Parameter (Mandatory = $true )][object []]$Items )
32+ param ([Parameter (Mandatory = $true )][AllowEmptyCollection ()][ object []]$Items )
3333 $set = New-Object ' System.Collections.Generic.HashSet[string]' ([System.StringComparer ]::OrdinalIgnoreCase)
3434 foreach ($item in $Items ) { $null = $set.Add ([string ]$item ) }
35- return $set
35+ return , $set
3636}
3737
3838function Diff-Sets {
@@ -54,6 +54,28 @@ function Diff-Sets {
5454 return [pscustomobject ]@ { Added = $added ; Removed = $removed }
5555}
5656
57+ function ConvertTo-PropertyMap {
58+ param ([Parameter (Mandatory = $false )]$Value )
59+
60+ $map = @ {}
61+ if ($null -eq $Value ) {
62+ return $map
63+ }
64+
65+ if ($Value -is [System.Collections.IDictionary ]) {
66+ foreach ($key in $Value.Keys ) {
67+ $map [[string ]$key ] = $Value [$key ]
68+ }
69+ return $map
70+ }
71+
72+ foreach ($property in $Value.PSObject.Properties ) {
73+ $map [[string ]$property.Name ] = $property.Value
74+ }
75+
76+ return $map
77+ }
78+
5779$before = Read-Snapshot - Path $BeforeSnapshotPath
5880$after = Read-Snapshot - Path $AfterSnapshotPath
5981
@@ -100,9 +122,9 @@ foreach ($k in $afterRegByPath.Keys) { $null = $allRegPaths.Add($k) }
100122
101123foreach ($path in ($allRegPaths | Sort-Object )) {
102124 $beforeValues = @ {}
103- if ($beforeRegByPath.ContainsKey ($path )) { $beforeValues = $beforeRegByPath [$path ].Values }
125+ if ($beforeRegByPath.ContainsKey ($path )) { $beforeValues = ConvertTo-PropertyMap - Value $beforeRegByPath [$path ].Values }
104126 $afterValues = @ {}
105- if ($afterRegByPath.ContainsKey ($path )) { $afterValues = $afterRegByPath [$path ].Values }
127+ if ($afterRegByPath.ContainsKey ($path )) { $afterValues = ConvertTo-PropertyMap - Value $afterRegByPath [$path ].Values }
106128
107129 $allNames = New-Object System.Collections.Generic.HashSet[string ] ([System.StringComparer ]::OrdinalIgnoreCase)
108130 foreach ($n in $beforeValues.Keys ) { $null = $allNames.Add ([string ]$n ) }
@@ -123,7 +145,7 @@ foreach ($path in ($allRegPaths | Sort-Object)) {
123145 }
124146 if ([string ]$bn -ne [string ]$an ) {
125147 $regDiffCount ++
126- if ($regDiffCount -le $MaxListItems ) { $reportLines.Add (" ~ $path \\$n : '$bn ' -> '$an '" ) }
148+ if ($regDiffCount -le $MaxListItems ) { $reportLines.Add (" ~ ${ path} \\${n} : '$bn ' -> '$an '" ) }
127149 }
128150 }
129151}
0 commit comments