Skip to content

Commit

Permalink
Adding a string match for insufficient permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian claesson committed Apr 2, 2024
1 parent 9b8418e commit 9da825c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/functions/Initialize-AzOpsEnvironment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,11 @@
$managementGroups = Get-AzManagementGroup -ErrorAction Stop
}
catch {
Write-AzOpsMessage -LogLevel Warning -LogString 'Initialize-AzOpsEnvironment.ManagementGroup.NoManagementGroupAccess'
return
if ($_.Exception.Message -match 'does not have authorization to perform action ''Microsoft.Management/register/action''') {
Write-AzOpsMessage -LogLevel Warning -LogString 'Initialize-AzOpsEnvironment.ManagementGroup.InsufficientPermissions'
} else {
Write-AzOpsMessage -LogLevel Warning -LogString 'Initialize-AzOpsEnvironment.ManagementGroup.NoManagementGroupAccess'
}
}

#region Validate root '/' permissions - different methods of getting current context depending on principalType
Expand Down

0 comments on commit 9da825c

Please sign in to comment.