Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Resource Removal: Add resource Group support for mg level deployments #1043

Merged
merged 5 commits into from
Feb 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,14 @@ function Get-DeploymentTargetResourceListInner {
[array]$resultSet = $resultSet | Where-Object { $_ -ne $deployment }
if ($deployment -match '/subscriptions/') {
# Subscription Level Child Deployments
[array]$resultSet += Get-DeploymentTargetResourceListInner -Name (Split-Path $deployment -Leaf) -Scope 'subscription'
if ($deployment -match '/resourceGroups/') {
# Resource Group Level Child Deployments (Used only if management group scope --> resource Group scope)
$name = Split-Path $deployment -Leaf
$resourceGroupName = $deployment.split('/resourceGroups/')[1].Split('/')[0]
[array]$resultSet += Get-DeploymentTargetResourceListInner -Name $name -ResourceGroupName $ResourceGroupName -Scope 'resourcegroup'
} else {
[array]$resultSet += Get-DeploymentTargetResourceListInner -Name (Split-Path $deployment -Leaf) -Scope 'subscription'
}
} else {
# Management Group Level Deployments
[array]$resultSet += Get-DeploymentTargetResourceListInner -name (Split-Path $deployment -Leaf) -scope 'managementgroup' -ManagementGroupId $ManagementGroupId
Expand Down