Skip to content

Commit

Permalink
Merge pull request #5795 from mpoulson/mpoulson/5359
Browse files Browse the repository at this point in the history
Add exception handling for delegatedPermissionClassifications with Ma…
  • Loading branch information
NikCharlebois authored Feb 19, 2025
2 parents e8d0861 + 5f4f647 commit 9f7ac53
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* ADOSecurityPolicy
* Fixes an issue where the resource threw an error trying to parse the default
values.
* AADServicePrincipal
* FIXES [#5359](https://github.com/microsoft/Microsoft365DSC/issues/5359) AADServicePrincipal fails on Managed Identities when DelegatedPermissions returns 500 response
* M365DSCUtil
* Add M365DSC prefix to `Remove-EmptyValue`.
* Fixes an issue with `Credential` property being escaped and indentation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,17 @@ function Get-TargetResource
}

[Array]$complexDelegatedPermissionClassifications = @()
$Uri = (Get-MSCloudLoginConnectionProfile -Workload MicrosoftGraph).ResourceUrl + "v1.0/servicePrincipals/$($AADServicePrincipal.Id)/delegatedPermissionClassifications"
$permissionClassifications = Invoke-MgGraphRequest -Uri $Uri -Method Get
#Managed Identities in AzureGov return exception when pulling delegatedPermissionClassifications
try
{
$Uri = (Get-MSCloudLoginConnectionProfile -Workload MicrosoftGraph).ResourceUrl + "v1.0/servicePrincipals/$($AADServicePrincipal.Id)/delegatedPermissionClassifications"
$permissionClassifications = Invoke-MgGraphRequest -Uri $Uri -Method Get
}
catch
{
Write-Verbose -Message "Service Principal didn't return delegated permission classifications. Expected for Managedidentities."
}

foreach ($permissionClassification in $permissionClassifications.Value)
{
$hashtable = @{
Expand Down

0 comments on commit 9f7ac53

Please sign in to comment.