Skip to content

Instantly share code, notes, and snippets.

@pmatthews05
Created June 18, 2020 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmatthews05/ce9cff4666c4974954858cfaa27e6a56 to your computer and use it in GitHub Desktop.
Save pmatthews05/ce9cff4666c4974954858cfaa27e6a56 to your computer and use it in GitHub Desktop.
#Get a access Token
$tokenResponse = az account get-access-token --resource-type ms-graph | convertFrom-Json
$body = @{
principalId = $ServicePrincipal.objectId
resourceId = $APIServicePrincipal.objectId
appRoleId = $appPermInfo.id
}
$appRoleAssignmentUrl = "https://graph.microsoft.com/v1.0/servicePrincipals/$($ServicePrincipal.objectId)/appRoleAssignments"
Invoke-RestMethod -Uri $appRoleAssignmentUrl -Headers @{Authorization = "Bearer $($tokenResponse.accessToken)" } -Method POST -Body $($body | ConvertTo-Json) -ContentType "application/json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment