PowerShell Function - Microsoft Cloud Tokens

At times it's necessary to be able to get tokens for different Microsoft cloud platforms without having access to Developer kits or .dll modules.  This function shows how different tokens can be gained using passwords, interactive OICD login, passwords etc.

It's one of my best examples of how agile code development needs refactoring after years of ongoing updates.  It will produce a hashtable that I can use in REST calls to the various Microsoft portals like Azure or Office 365.

I'm providing the function warts & all primarily because other examples on this site reference getting a Header for API automation.

Core elements of this script (I believe) came from Adam Bertram... one of my heros from years of developing automation.  

This code is great for getting a Header & for a lot of administration a short token lifetime is fine.  When using an "Interactive" login for long running tasks, you really need to be using Refresh Tokens.  That use case i'll demonstrate separately.

https://github.com/LaurieRhodes/AZRest/blob/main/public/Get-Header.md

 

Tags