Thursday, June 20, 2019

Using MFA Accounts to connect to SPO online using PnP


Recently our organization have MFA (Multi-factor Authentication) enabled on all the Admin IDs. Which means once you are authenticated, you will be challenged again to prove your identity by giving a authentication code which will be sent to your mobile or MSFT calls your authorized identity phone to confirm its you who are logging in. Until now we used to store the password in an encrypted key and passed those credentials in the script. After MFA enabled, we need to use the paramter called 'use-weblogin'. Once this parameter is used who will be challenged second time while running the script, after successful verification rest of the script runs.

For instance Before MFA our code for connection
Connect-PnPOnline -Url https://yourAdminPortalURL -Credentials (Get-Credential)

After MFA our code for connection
Connect-PnPOnline -Url https://yourAdminPortalURL -UseWebLogin

Kindly let me know if there is any other ways to run the admin scripts automatically without weblogin paramter. May be there is way using Function and Azure Run books, i haven' explored that route much. Thanks for taking time to read this.

References: 

https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/connect-pnponline?view=sharepoint-ps
HTH

Vinay. 

No comments:

Post a Comment