Skip to content

Commit 917b4c4

Browse files
committed
bypass confirmation in plan mode
1 parent 9ed2877 commit 917b4c4

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

src/ALZ/Public/Remove-PlatformLandingZone.ps1

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -986,14 +986,19 @@ function Remove-PlatformLandingZone {
986986
if(-not $BypassConfirmation) {
987987
Write-ToConsoleLog "The following Management Groups will be processed for removal:"
988988
$managementGroupsFound | ForEach-Object { Write-ToConsoleLog "Management Group: $($_.Name) ($($_.DisplayName))" -NoNewLine }
989-
$warningMessage = "ALL THE MANAGEMENT GROUP STRUCTURES ONE LEVEL BELOW THE LISTED MANAGEMENT GROUPS WILL BE PERMANENTLY DELETED"
990-
if($DeleteTargetManagementGroups) {
991-
$warningMessage = "ALL THE LISTED MANAGEMENTS GROUPS AND THEIR CHILDREN WILL BE PERMANENTLY DELETED"
992-
}
993-
$continue = Invoke-PromptForConfirmation -message $warningMessage
994-
if(-not $continue) {
995-
Write-ToConsoleLog "Exiting..."
996-
return
989+
990+
if($PlanMode) {
991+
Write-ToConsoleLog "Skipping confirmation for plan mode"
992+
} else {
993+
$warningMessage = "ALL THE MANAGEMENT GROUP STRUCTURES ONE LEVEL BELOW THE LISTED MANAGEMENT GROUPS WILL BE PERMANENTLY DELETED"
994+
if($DeleteTargetManagementGroups) {
995+
$warningMessage = "ALL THE LISTED MANAGEMENTS GROUPS AND THEIR CHILDREN WILL BE PERMANENTLY DELETED"
996+
}
997+
$continue = Invoke-PromptForConfirmation -message $warningMessage
998+
if(-not $continue) {
999+
Write-ToConsoleLog "Exiting..."
1000+
return
1001+
}
9971002
}
9981003
}
9991004

@@ -1212,10 +1217,15 @@ function Remove-PlatformLandingZone {
12121217
if(-not $BypassConfirmation) {
12131218
Write-ToConsoleLog "The following Subscriptions were provided or discovered during management group cleanup:"
12141219
$subscriptionsFinal | ForEach-Object { Write-ToConsoleLog "Name: $($_.Name), ID: $($_.Id)" -NoNewline }
1215-
$continue = Invoke-PromptForConfirmation -Message "ALL RESOURCE GROUPS IN THE LISTED SUBSCRIPTIONS WILL BE PERMANENTLY DELETED UNLESS THEY MATCH RETENTION PATTERNS"
1216-
if(-not $continue) {
1217-
Write-ToConsoleLog "Exiting..."
1218-
return
1220+
1221+
if($PlanMode) {
1222+
Write-ToConsoleLog "Skipping confirmation for plan mode"
1223+
} else {
1224+
$continue = Invoke-PromptForConfirmation -Message "ALL RESOURCE GROUPS IN THE LISTED SUBSCRIPTIONS WILL BE PERMANENTLY DELETED UNLESS THEY MATCH RETENTION PATTERNS"
1225+
if(-not $continue) {
1226+
Write-ToConsoleLog "Exiting..."
1227+
return
1228+
}
12191229
}
12201230
}
12211231
}

0 commit comments

Comments
 (0)