Forum Discussion
Joshua_Thompson
Sep 13, 2021Copper Contributor
Connect-PNPOnline - Automate logon
I can successfully connect to SharePoint online using my admin account and the below command.
Connect-PnPOnline -Url "https://(sitename).sharepoint.com/sites/(subsite)" -Interactive
During this process I get the interactive logon prompt, I enter my standard password, I complete the MFA prompt and I am allowed access.
I need to be able to connect with no user prompts.
I thought I would use an app password to avoid the MFA prompts but when I try the below command, enter my username and app password, power shells returns with "Error validating credentials due to invalid username or password".
Connect-PnPOnline -Url "https://(sitename).sharepoint.com/sites/(subsite)"
Are app passwords no longer support for this?
What are my alternatives?
- SteveMacNZIron Contributor
Hi Joshua - off the top of my head I would suggest looking into Azure Automation using runbooks Manage Office 365 services using Azure Automation | Microsoft Docs has more information
- Use the -AppId -AppSecret parameters. You need to have a matching app registration in Azure AD.
- Joshua_ThompsonCopper ContributorThanks SteveMacNZ and @Vasil for the recommendations!