This post is sort of a follow up on a previous post where I attempted to prevent a duplicate login when accessing both Azure Resource Manager and Azure AD in the same PowerShell script, still without success by the way. But I can use something I learned there to accomplish something else: getting an access token for working with the Azure REST API.
Getting the access token
Getting the access token follows the same steps as described in my earlier post:
Of course, you have to login using an account that has sufficient permissions to access the REST API.
Using the token
We can now use the token to call the REST API. For example, to retrieve all the resource groups in a subscription. The easiest way is via the
Invoke-RestMethod PowerShell cmdlet:
The original article was posted on: ronaldwildenberg.com