Skip to content

Commit

Permalink
Add no deletion for exemptions when ownedonly (#419)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Watherston <Anthony.Watherston@microsoft.com>
  • Loading branch information
anwather and Anthony Watherston authored Nov 13, 2023
1 parent 8c4b78b commit 4073570
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Scripts/Helpers/Build-ExemptionsPlan.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ function Build-ExemptionsPlan {
}
}
else {
if (!$AllAssignments.ContainsKey($policyAssignmentId) -and $deleteOrpahed) {
if (!$AllAssignments.ContainsKey($policyAssignmentId) -and $deleteOrphaned) {
Write-Warning "Orphaned exemption (name=$name, scope=$scope) in definitions"
continue
}
Expand Down Expand Up @@ -433,7 +433,17 @@ function Build-ExemptionsPlan {
$removed = $true
}
}
$shallDelete = Confirm-DeleteForStrategy -PacOwner $pacOwner -Strategy $strategy -Status $status -DeleteExpired $deleteExpired -DeleteOrphaned $deleteOrphaned -Removed $removed
if ($null -eq $exemption.metadata.pacOwnerId -and $PacEnvironment.desiredState.strategy -eq "ownedOnly") {
$shallDelete = $false
}
else {
$shallDelete = Confirm-DeleteForStrategy -PacOwner $pacOwner `
-Strategy $strategy `
-Status $status `
-DeleteExpired $deleteExpired `
-DeleteOrphaned $deleteOrphaned `
-Removed $removed
}

if ($shallDelete) {
switch ($status) {
Expand Down

0 comments on commit 4073570

Please sign in to comment.