Skip to content

Instantly share code, notes, and snippets.

@nathanmcnulty
Created May 14, 2025 06:16
Show Gist options
  • Save nathanmcnulty/3c6d12d253a99aebe22b355ddd7341d0 to your computer and use it in GitHub Desktop.
Save nathanmcnulty/3c6d12d253a99aebe22b355ddd7341d0 to your computer and use it in GitHub Desktop.
Add permissions to Managed Identity
$SP_ID = '3b3c5db1-c095-41c7-af10-2a958ccaf91a'
Connect-MgGraph -Scopes appRoleAssignment.ReadWrite.All,Application.Read.All,Group.ReadWrite.All
$GraphSP = Get-MgServicePrincipal -Filter "appId eq '00000003-0000-0000-c000-000000000000'"
$AppRole = $GraphSP.AppRoles | Where-Object {$_.Value -eq "SecurityEvents.Read.All" -and $_.AllowedMemberTypes -contains "Application"}
New-MgServicePrincipalAppRoleAssignment -AppRoleId $AppRole.Id -ServicePrincipalId $SP_ID -ResourceId $GraphSP.Id -PrincipalId $SP_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment