Merge pull request #429 from McKenzieCo/fix/silent-bulk-compare-op-addition

Fix silent bulk compare crash: op_Addition on PSObject
This commit is contained in:
Mikael Karlsson
2026-08-06 21:30:15 +10:00
committed by GitHub
+8 -8
View File
@@ -706,7 +706,7 @@ function Start-BulkCompareExportObjects
$objName = Get-GraphObjectName (?? $compObj.Object1 $compObj.Object2) $item.ObjectType $objName = Get-GraphObjectName (?? $compObj.Object1 $compObj.Object2) $item.ObjectType
foreach($compValue in $compObj.Result) foreach($compValue in $compObj.Result)
{ {
$compValue += [PSCustomObject]@{ $compResultValue = [PSCustomObject]@{
ObjectName = $objName ObjectName = $objName
Id = $compObj.Id Id = $compObj.Id
Type = $compObj.ObjectType.Title Type = $compObj.ObjectType.Title
@@ -719,23 +719,23 @@ function Start-BulkCompareExportObjects
Match = $compValue.Match Match = $compValue.Match
} }
if($global:chkBulkCompareRemoveOData.IsChecked -and ($compValue.Value1 -like "@odata*" -or $compValue.Value2 -like "@odata*")) { if($global:chkBulkCompareRemoveOData.IsChecked -and ($compResultValue.Value1 -like "@odata*" -or $compResultValue.Value2 -like "@odata*")) {
foreach($prop in $('Value1','Value2')) foreach($prop in $('Value1','Value2'))
{ {
$tmpValue1 = "" $tmpValue1 = ""
$tmpValue2 = "" $tmpValue2 = ""
$vauleString = $compValue.$prop $vauleString = $compResultValue.$prop
if($vauleString -is [String]) { if($vauleString -is [String]) {
$vauleString = $vauleString -replace $compValue.Id, "" $vauleString = $vauleString -replace $compResultValue.Id, ""
$tmpObj = $compValue.$prop | ConvertFrom-Json $tmpObj = $compResultValue.$prop | ConvertFrom-Json
if($compValue.$prop -and $compValue.$prop -like "@odata*") { if($compResultValue.$prop -and $compResultValue.$prop -like "@odata*") {
Remove-GraphODataProperties $tmpObj.$prop | ConvertTo-Json -Depth 50 | Set-Variable -Name "tmp$prop" Remove-GraphODataProperties $tmpObj.$prop | ConvertTo-Json -Depth 50 | Set-Variable -Name "tmp$prop"
} }
} }
} }
$compValue.Match = $tmpValue1 -eq $tmpValue2 $compResultValue.Match = $tmpValue1 -eq $tmpValue2
} }
$compResultValues += $compValue $compResultValues += $compResultValue
} }
} }