From 94ecff553b19771e7409551bd6abd2f280ebb1b5 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Thu, 28 Apr 2022 00:13:10 +0200 Subject: [PATCH] Added role assignment removal to removal logic --- .../resourceRemoval/helper/Invoke-ResourceRemoval.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/utilities/pipelines/resourceRemoval/helper/Invoke-ResourceRemoval.ps1 b/utilities/pipelines/resourceRemoval/helper/Invoke-ResourceRemoval.ps1 index a00be1a89d..1a37997bac 100644 --- a/utilities/pipelines/resourceRemoval/helper/Invoke-ResourceRemoval.ps1 +++ b/utilities/pipelines/resourceRemoval/helper/Invoke-ResourceRemoval.ps1 @@ -70,6 +70,13 @@ function Invoke-ResourceRemoval { # Not a 'resource' that can be removed, but represents settings on the RSV. The config is deleted with the RSV break } + 'Microsoft.Authorization/roleAssignments' { + $idElem = $ResourceId.Split('/') + $scope = $idElem[0..($idElem.Count - 5)] -join '/' + $roleAssignmentsOnScope = Get-AzRoleAssignment -Scope $scope + $roleAssignmentsOnScope | Where-Object { $_.RoleAssignmentId -eq $ResourceId } | Remove-AzRoleAssignment + break + } 'Microsoft.RecoveryServices/vaults' { # Pre-Removal # -----------