Grant API permissions for APP using Powershell

New Contributor



I want to create an azure AD app using PowerShell. That works fine, I create my app, set redirect-url and can also upload the certificate I need.

Now I want to enable MS Graph and Office 365 Exchange online API using PowerShell but I can't find commands for that.

Who can help me?

2 Replies

No ideas on this? Is there absolutely no possibility to do that programatically?

$tenantId = $args[0]
$appName = $args[1]
$subscriptionId = $args[2]
$secret = $args[3]
$cert = $args[4]

$replyUrl = ""

Connect-AzAccount -Tenant $tenantId -Subscription $subscriptionId


$printerCreate = '"90c30bed-6fd1-4279-bf39-714069619721"'
$item5 = @"
{"id": $printerCreate,"type": "Scope"}
$item9 = @"
{"id": $printJobManageAll,"type": "Role"}


$itemA = @"
{"id": $printTaskDefinition,"type": "Role"}
$resources = @"
[{ "resourceAppId": $graphId, "resourceAccess": [$item5,$item9,$itemA]}]
"@ | ConvertTo-Json

$myApiAppRegistration = az ad app create --display-name $appName --password $secret --reply-urls $replyUrl --required-resource-accesses $resources --available-to-other-tenants false
$myApiAppRegistrationResult = ($myApiAppRegistration | ConvertFrom-Json)