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

%3CLINGO-SUB%20id%3D%22lingo-sub-1744228%22%20slang%3D%22en-US%22%3EHow%20to%20create%20powershell%20to%20schedule%20task%20script%20Connect-AzureAD%20without%20credentials-%20MFA%20enabled%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1744228%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20there%2C%3CBR%20%2F%3EI%20have%20created%20some%20scirpts%20in%20powershell%20to%26nbsp%3BGet-AzureADGroup%20and%20Members%20but%20now%20i%20would%20like%20to%20schedule%20it.%3CBR%20%2F%3EThe%20issue%20is%20we%20are%20using%20MFA%20and%20don't%20know%20what%20needs%20to%20be%20done%20to%20be%20able%20to%20write%20a%20script%20that%20would%20run%20successfully%20without%20having%20to%20get%20prompted%20to%20login.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20ideas%20would%20be%20appreciated.%3CBR%20%2F%3EWhat%20are%20the%20options%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1744228%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20AD%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1744452%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20create%20powershell%20to%20schedule%20task%20script%20Connect-AzureAD%20without%20credentials-%20MFA%20enable%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1744452%22%20slang%3D%22en-US%22%3EYour%20best%20bet%20would%20be%20to%20use%20the%20Graph%20API%20with%20'application%20permissions'.%20This%20doesn't%20need%20an%20account%2C%20just%20an%20app%20registration.%3CBR%20%2F%3E%3CBR%20%2F%3ECheck%20out%20this%20blog%20%3D%26gt%3B%20%3CA%20href%3D%22https%3A%2F%2F365bythijs.be%2F2020%2F09%2F17%2Fan-introduction-into-the-graph-api%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2F365bythijs.be%2F2020%2F09%2F17%2Fan-introduction-into-the-graph-api%2F%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EAnd%20the%20Graph%20API%20docs%20%3D%26gt%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fgroup-list-members%3Fview%3Dgraph-rest-1.0%26amp%3Btabs%3Dhttp%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fgroup-list-members%3Fview%3Dgraph-rest-1.0%26amp%3Btabs%3Dhttp%3C%2FA%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1747618%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20create%20powershell%20to%20schedule%20task%20script%20Connect-AzureAD%20without%20credentials-%20MFA%20enable%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1747618%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F186539%22%20target%3D%22_blank%22%3E%40Thijs%20Lecomte%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3EThanks%20Thijs.%3CBR%20%2F%3EIs%20there%20any%20other%20option%20apart%20from%20using%20Graph%20API%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EAbout%20this%20other%20option%20here%20below%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ferjenrijnders.nl%2F2018%2F08%2F30%2Fazuread-login-without-credentials-unattended%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Ferjenrijnders.nl%2F2018%2F08%2F30%2Fazuread-login-without-credentials-unattended%2F%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
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
Highlighted
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
Highlighted