Forum Discussion
Using Connect-SPOService in Azure Runbooks with MFA Enabled Account
- 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 Thanks for the info. So I created an app ID and secret, and then created a new credentials in my Azure Automation account (called runbooksappidandsecret) using the app id and secret.
Then I try to use that credential in my script:
Connect-SPOService : The 'username' argument is invalid. At line:9 char:1 + Connect-SPOService -Url "$adminUrl" -Credential $creds + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Connect-SPOService], ArgumentException + FullyQualifiedErrorId : System.ArgumentException,Microsoft.Online.SharePoint.PowerShell.ConnectSPOService
I am having the same problem but I am actually trying to access PNP Cmdlts. I'm fairly new so I am curious on the process of " So I created an app ID and secret, and then created a new credentials in my Azure Automation account (called runbooksappidandsecret) using the app id and secret."
Could you tell me the process to get to this point?
Many thanks
Rob
- Paul BullockFeb 24, 2021MVP
RobOnyxPublishing - I have created a while ago a sample for the PnP PowerShell with scripts to set this up using App Only, Azure AD App, and Azure Automation -
https://github.com/pnp/powershell/tree/dev/samples/Connect.AzureAutomation
hope it helps.