Grant API permissions for APP using Powershell

Copper Contributor

Hi,

 

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 = "https://www.kofax.com/products/mobile-capture-platform"

Connect-AzAccount -Tenant $tenantId -Subscription $subscriptionId

$graphId='"00000003-0000-0000-c000-000000000000"'

$printerCreate = '"90c30bed-6fd1-4279-bf39-714069619721"'
$item5 = @"
{"id": $printerCreate,"type": "Scope"}
"@
$printJobManageAll='"58a52f47-9e36-4b17-9ebe-ce4ef7f3e6c8"'
$item9 = @"
{"id": $printJobManageAll,"type": "Role"}
"@

$printTaskDefinition='"456b71a7-0ee0-4588-9842-c123fcc8f664"'

$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)
$appId=$myApiAppRegistrationResult.appId
$objectId=$myApiAppRegistrationResult.objectId
$secret=$myApiAppRegistrationResult.passwordCredentials