Skip to content

Instantly share code, notes, and snippets.

@pmatthews05
Last active June 18, 2020 15:27
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/981531621a467d61c3bd1701459887ae to your computer and use it in GitHub Desktop.
Save pmatthews05/981531621a467d61c3bd1701459887ae 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 appRolesPermission
$appRolePermInfo = az ad sp show --id $($APIServicePrincipal.appId) --query "appRoles[?value=='Directory.ReadWrite.All']" | ConvertFrom-Json
#Add Permission (Role means Application)
az ad app permission add --id $appId --api $($APIServicePrincipal.appId) --api-permissions $($appRolePermInfo.id)=Role
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment