From 088245a9d55425b3d4c96c039a0e5376322925c0 Mon Sep 17 00:00:00 2001 From: Jared Holgate Date: Tue, 9 Jul 2024 15:49:47 +0100 Subject: [PATCH] Add prefix param to avoid confusion --- accelerator/scripts/destroy-landing-zone.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/accelerator/scripts/destroy-landing-zone.ps1 b/accelerator/scripts/destroy-landing-zone.ps1 index 6967efc01..94cf66669 100644 --- a/accelerator/scripts/destroy-landing-zone.ps1 +++ b/accelerator/scripts/destroy-landing-zone.ps1 @@ -2,6 +2,7 @@ param ( [bool]$whatIfEnabled = $true, + [string]$prefix = $env:PREFIX, [string]$intermediateRootGroupID = $env:MANAGEMENT_GROUP_ID, [string]$tenantRootGroupID = $env:ROOT_PARENT_MANAGEMENT_GROUP_ID, [string]$connectivitySubscriptionId = $env:CONNECTIVITY_SUBSCRIPTION_ID, @@ -87,7 +88,7 @@ ForEach ($subscription in $subscriptionsToClean) { $resourceGroupsToRemove = @() ForEach ($resourceGroup in $resourceGroups) { - if ($resourceGroup.ResourceGroupName -like "rg-$intermediateRootGroupID-*") { + if ($resourceGroup.ResourceGroupName -like "rg-$prefix*") { $resourceGroupsToRemove += $resourceGroup.ResourceGroupName } } @@ -104,7 +105,7 @@ ForEach ($subscription in $subscriptionsToClean) { $deploymentsToRemove = @() ForEach ($deployment in $subDeployments) { - if ($deployment.DeploymentName -like "$intermediateRootGroupID-*" -and $deployment.ProvisioningState -eq "Succeeded") { + if ($deployment.DeploymentName -like "$prefix*" -and $deployment.ProvisioningState -eq "Succeeded") { $deploymentsToRemove += $deployment } }