Forum Discussion
Russell Gove
May 10, 2019Iron Contributor
Using Connect-SPOService in Azure Runbooks with MFA Enabled Account
Hi, I'm trying to move my SPO Admin scripts to Azure Runbooks. My Admin Account is MFA enabled. When I run the commands: $creds=Get-AutomationPSCredential -Name 'MyCredentials' Connect-SPOServic...
- May 13, 2019
Hi Russell Gove, no you can't use an MFA account when doing this level of automation unfortunately as the usual behaviour is to open a popup to request the authentication. There are a couple of options which you have available to you:
1. Use a "service account" which doesn't have MFA (this is the easiest way, just ensure you have a strong password on the account)
2. Connect using App ID and Secret
I hope that helps
Beau Cameron
May 14, 2019MVP
Russell Gove My apologies as I wasn't fully thinking in this regard. SPO Commandlets do not support app only credentials... I forget because I only use the PnP Commandlets (as they have more features than the SPO commandlet).
RobOnyxPublishing
Feb 17, 2021Copper Contributor
Beau Cameron How do you connect to PnP using the App ID and Secret. I have created the App and secret but I am stuck at that point... Your help would be hugely appreciated
- Don KirkhamFeb 18, 2021MVP
RobOnyxPublishing All of the options for connecting via PnP PowerShell can be found at https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/connect-pnponline
The Client Secret option is Example #3 on the page. Microsoft's recommendation for the most secure method is to use a Certificate (Examples #6-8, but I prefer #7). It's a few extra steps to create and attach the Certificate to the App ID, but just as simple as the Client Secret approach after the initial setup, IMO. There is a link under the examples that shows all the steps to set it up.