Powershell – Do “Grant Permissions” action on Azure AD Application with Powershell

Question:

I’m creating an Azure AD application using AzureAD module to call Microsoft Graph API. I can successfully generate the access token. But, when I try to call the API I have an error “message”: “Invalid scope claims/roles.”.

When I click on “Grant Permissions” button in my created application in Azure Portal and retry the call to API, the call is working.

I don’t find anywhere how to do this “Grant Permissions” actions with Powershell. Is there a way to do that ?

Thanks

Damien

Answer:

There is an easy way to do this (as admin), it requires you have the AzureAD and AzureRM modules installed for Powershell and is not supported by Microsoft.

Original post / reference to my blog is here: http://www.lieben.nu/liebensraum/2018/04/how-to-grant-oauth2-permissions-to-an-azure-ad-application-using-powershell-unattended-silently/

The specific code sample that should help you accomplish this:

Source:

Powershell – Do “Grant Permissions” action on Azure AD Application with Powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply