Skip to content

Instantly share code, notes, and snippets.

@pmatthews05
Last active June 18, 2020 14:50
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/3a0da34eb8babc1f84ac2443148568be to your computer and use it in GitHub Desktop.
Save pmatthews05/3a0da34eb8babc1f84ac2443148568be to your computer and use it in GitHub Desktop.
#Get Graph APIServicePrinicpal information
$APIServicePrincipal = az ad sp list --query "[?appDisplayName=='Microsoft Graph'].{appId:appId,objectId:objectId}" --all | ConvertFrom-Json
#Get Directory.ReadWrite.All oauth2Permission
$delegatePermInfo = az ad sp show --id $($APIServicePrincipal.appId) --query "oauth2Permissions[?value=='Directory.ReadWrite.All']" | ConvertFrom-Json
#Add Permission (Scope means Delegate)
az ad app permission add --id $appId --api $($APIServicePrincipal.appId) --api-permissions $($delegatePermInfo.id)=Scope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment