Skip to content

Commit fe26351

Browse files
anwatherAnthony Watherston
and
Anthony Watherston
authored
Revert updates to version comparison - issue with ARG (#971)
Co-authored-by: Anthony Watherston <Anthony.Watherston@microsoft.com>
1 parent b595da9 commit fe26351

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

Scripts/Helpers/Confirm-PolicyDefinitionsInPolicySetMatch.ps1

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,37 +42,37 @@ function Confirm-PolicyDefinitionsInPolicySetMatch {
4242

4343
# Validate the Azure definitionVersion with the local definitionVersion, if the local definitionVersion doesn't exist and the Azure definitionVersion is not equal to latest policy version then return false
4444
# This addresses an error that occurs when there is a null value in the definitionVersion field that cropped up when we removed the variable prior to processing to fix a bug spotted in Build-HydrationDeploymentPlans where the values were retained, and adversely affecting the update information.
45-
try {
46-
if ($null -eq $item1.definitionVersion -and $null -eq $item2.definitionVersion) {
47-
# Compare-SemanticVersion -Version1 0 -Version2 0 is always 0, so we forego the calculation and set it
48-
$definitionVersionMatches = 0
49-
}
50-
elseif ($null -eq $item1.definitionVersion) {
51-
# Compare-SemanticVersion -Version1 0 -Version2 (anything not 0) is always -1, so we forego the calculation and set it
52-
# $definitionVersionMatches = Compare-SemanticVersion -Version1 0 -Version2 $item2.definitionVersion
53-
$definitionVersionMatches = -1
54-
}
55-
elseif ($null -eq $item2.definitionVersion) {
56-
# Compare-SemanticVersion -Version1 (anything not 0) -Version2 0 is always 1, so we forego the calculation and set it
57-
# $definitionVersionMatches = Compare-SemanticVersion -Version1 $item1.definitionVersion -Version2 0
58-
$definitionVersionMatches = 1
59-
}
60-
else {
61-
# If neither of the definitionVersion values are null, then the compare can proceed without error
62-
$definitionVersionMatches = Compare-SemanticVersion -Version1 $($item1.definitionVersion ?? $Definitions[$item1.policyDefinitionId].properties.version ?? '1.*.*') -Version2 $($item2.definitionVersion ?? $Definitions[$item1.policyDefinitionId].properties.version ?? '1.*.*')
63-
}
64-
}
65-
catch {
66-
Write-Information "Comparison has generated an error."
67-
Write-Information "Item1: $($item1.policyDefinitionId) $($item1.policySetDefinitionId) $($item1.policyDefinitionName) $($item1.policySetDefinitionName)"
68-
Write-Information "Item2: $($item2.policyDefinitionId) $($item2.policySetDefinitionId) $($item2.policyDefinitionName) $($item2.policySetDefinitionName)"
69-
continue
70-
}
71-
if ($definitionVersionMatches -ne 0) {
72-
Write-Verbose "Definition Id: $($item1.policyDefinitionId)"
73-
Write-Verbose "DefinitionVersion does not match: Azure: $($item1.definitionVersion), Local: $($item2.definitionVersion)"
74-
return $false
75-
}
45+
# try {
46+
# if ($null -eq $item1.definitionVersion -and $null -eq $item2.definitionVersion) {
47+
# # Compare-SemanticVersion -Version1 0 -Version2 0 is always 0, so we forego the calculation and set it
48+
# $definitionVersionMatches = 0
49+
# }
50+
# elseif ($null -eq $item1.definitionVersion) {
51+
# # Compare-SemanticVersion -Version1 0 -Version2 (anything not 0) is always -1, so we forego the calculation and set it
52+
# # $definitionVersionMatches = Compare-SemanticVersion -Version1 0 -Version2 $item2.definitionVersion
53+
# $definitionVersionMatches = -1
54+
# }
55+
# elseif ($null -eq $item2.definitionVersion) {
56+
# # Compare-SemanticVersion -Version1 (anything not 0) -Version2 0 is always 1, so we forego the calculation and set it
57+
# # $definitionVersionMatches = Compare-SemanticVersion -Version1 $item1.definitionVersion -Version2 0
58+
# $definitionVersionMatches = 1
59+
# }
60+
# else {
61+
# # If neither of the definitionVersion values are null, then the compare can proceed without error
62+
# $definitionVersionMatches = Compare-SemanticVersion -Version1 $($item1.definitionVersion ?? $Definitions[$item1.policyDefinitionId].properties.version ?? '1.*.*') -Version2 $($item2.definitionVersion ?? $Definitions[$item1.policyDefinitionId].properties.version ?? '1.*.*')
63+
# }
64+
# }
65+
# catch {
66+
# Write-Information "Comparison has generated an error."
67+
# Write-Information "Item1: $($item1.policyDefinitionId) $($item1.policySetDefinitionId) $($item1.policyDefinitionName) $($item1.policySetDefinitionName)"
68+
# Write-Information "Item2: $($item2.policyDefinitionId) $($item2.policySetDefinitionId) $($item2.policyDefinitionName) $($item2.policySetDefinitionName)"
69+
# continue
70+
# }
71+
# if ($definitionVersionMatches -ne 0) {
72+
# Write-Verbose "Definition Id: $($item1.policyDefinitionId)"
73+
# Write-Verbose "DefinitionVersion does not match: Azure: $($item1.definitionVersion), Local: $($item2.definitionVersion)"
74+
# return $false
75+
# }
7676

7777
$groupNames1 = $item1.groupNames
7878
$groupNames2 = $item2.groupNames

0 commit comments

Comments
 (0)