Skip to content

Instantly share code, notes, and snippets.

@AlexanderHolmeset
Created January 25, 2023 14:41
Show Gist options
  • Save AlexanderHolmeset/037449c87ed7a3a16a884014825c072d to your computer and use it in GitHub Desktop.
Save AlexanderHolmeset/037449c87ed7a3a16a884014825c072d to your computer and use it in GitHub Desktop.
$graphScope = "LearningContent.ReadWrite.All"
$servicePrincipalObjectId = "Enter object ID of Logic App here"
$TenantID = "contoso.onmicrosoft.com"
Install-Module Microsoft.Graph
Connect-MgGraph -Scope “AppRoleAssignment.ReadWrite.All”,”Application.Read.All” -tenantId $TenantID
$graph = Get-MgServicePrincipal -Filter "AppId eq '00000003-0000-0000-c000-000000000000'"
$graphAppRole = $graph.AppRoles | ? Value -eq $graphScope
$appRoleAssignment = @{
"principalId" = $servicePrincipalObjectId
"resourceId" = $graph.Id
"appRoleId" = $graphAppRole.Id
}
New-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $servicePrincipalObjectId -BodyParameter $appRoleAssignment | Format-List
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment