From 2cb2001d1aab7d951184c33d672c204817c34055 Mon Sep 17 00:00:00 2001 From: Jelle Broekhuijsen Date: Mon, 4 Sep 2023 09:42:05 +0200 Subject: [PATCH] change error handling --- Remove-AzManagementGroups.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Remove-AzManagementGroups.ps1 b/Remove-AzManagementGroups.ps1 index bda59e3..863fd34 100644 --- a/Remove-AzManagementGroups.ps1 +++ b/Remove-AzManagementGroups.ps1 @@ -8,7 +8,7 @@ .PARAMETER TenantId The tenant id to run the script against .NOTES - Version: 1.1.1 + Version: 1.1.2 Author: Jelle Broekhuijsen - jll.io Consultancy Creation Date: 8/8/2023 @@ -64,8 +64,7 @@ do { Write-Output "Attempting to remove management group: $($managementGroup.Name)" $result = Remove-AzManagementGroup -GroupName $managementGroup.Name -ErrorAction Continue if ($result -ne $true) { - Write-Warning "Failed to remove management group: $($managementGroup.Name)" - $localFailures.Add($result) + Write-Warning "'Remove-AzManagementGroup -GroupId $($managementGroup.Name)' did not return 'true', this will result in the script retrying the removal of this management group" } } else {