Forum Discussion

Joshua_Thompson's avatar
Joshua_Thompson
Copper Contributor
Sep 13, 2021

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?

3 Replies

  • Use the -AppId -AppSecret parameters. You need to have a matching app registration in Azure AD.
  • SteveMacNZ's avatar
    SteveMacNZ
    Iron Contributor

    Joshua_Thompson 

     

    Hi Joshua - off the top of my head I would suggest looking into Azure Automation using runbooks https://docs.microsoft.com/en-us/azure/automation/manage-office-365 has more information

Resources