How to create powershell to schedule task script Connect-AzureAD without credentials- MFA enabled

Iron Contributor

Hi there,
I have created some scirpts in powershell to Get-AzureADGroup and Members but now i would like to schedule it.
The issue is we are using MFA and don't know what needs to be done to be able to write a script that would run successfully without having to get prompted to login.

 

Any ideas would be appreciated.
What are the options?

 

3 Replies
Your best bet would be to use the Graph API with 'application permissions'. This doesn't need an account, just an app registration.

Check out this blog => https://365bythijs.be/2020/09/17/an-introduction-into-the-graph-api/

And the Graph API docs =>https://docs.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-1.0&tabs=http