Hi @ALVIN LEUNG (CLOUD-ISD-OOCLL/HKG) ,
deleting all Resource Groups with the same name in different Azure Subscriptions is possible using PowerShell and the Az
module (not "one button" but "one script with a few lines").
You need to select the Azure Subscription one after the other and check if the Resource Group is existing.
Maybe this PowerShell script is helpful to get started:
$rg2Delete = "test-rg"
Get-AzSubscription | ForEach-Object {
Select-AzSubscription $_
$rgObject = Get-AzResourceGroup -Name $rg2Delete -ErrorAction SilentlyContinue
if ($rgObject) {
Remove-AzResourceGroup -Name $rg2Delete -WhatIf
}
else {
Write-Output "RG $rg2Delete not found in $($_.Name)"
}
}
Just remove the -WhatIf
parameter in line 6 and the resource groups will be deleted.
With the parameter -WhatIf
it shows what would happen if the cmdlet Remove-AzResourceGroup
runs. But it's not removing anything.
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten