Skip to content

Commit

Permalink
Only remove deployments created by this module
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredfholgate committed Jul 9, 2024
1 parent 4920d44 commit 11a912a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions accelerator/scripts/destroy-landing-zone.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,19 @@ ForEach ($subscription in $subscriptionsToClean) {

Write-Host "Removing All Successful Subscription Deployments for: $($subscription.name)" -ForegroundColor Yellow

# For each Subscription level deployment, remove it
$subDeployments | ForEach-Object -Parallel {
if($_.ProvisioningState -eq "Succeeded") {
Write-Host "Removing $($_.DeploymentName) ..." -ForegroundColor Red
Remove-AzSubscriptionDeployment -Id $_.Id | Out-Null
$deploymentsToRemove = @()
ForEach ($deployment in $subDeployments) {
if ($deployment.DeploymentName -like "$intermediateRootGroupID-*" -and $deployment.ProvisioningState -eq "Succeeded") {
$deploymentsToRemove += $deployment
}
}

# For each Subscription level deployment, remove it
$deploymentsToRemove | ForEach-Object -Parallel {
Write-Host "Removing $($_.DeploymentName) ..." -ForegroundColor Red
Remove-AzSubscriptionDeployment -Id $_.Id | Out-Null
}

# Set MDFC tier to Free for each Subscription
if ($resetMdfcTierOnSubs) {
Write-Host "Resetting MDFC tier to Free for Subscription: $($subscription.name)" -ForegroundColor Yellow
Expand Down

0 comments on commit 11a912a

Please sign in to comment.