I created PowerShell script that runs well in PowerShell-ISE. It autologin with credential popup and works as expected.

Problem: While same script I added to Task Scheduler then it prompts credential and wait until select the user, once user select manually then it works as expected. But I want autologin and execute without prompt credential.

Command: Connect-PnPOnline -Url "https://contoso.sharepoint.com" -UseWebLogin Note: Only -UseWebLogin option is applicable. Area: Office365, SharePoint Online

1 Answer 1


The best way around this is to use credential manager. See this Blog PNP and Cred Manager

The basics are that you add a credential to the credential manager on the server that is running this task, then in your PNP script you connect like this: note that "Admin" is the name that you give the credential when you create it.

Connect-PnPOnline -Url "https://tenant.sharepoint.com/sites/AwesomeSite" -Credentials:Admin

  • When use -Credential at that time it throws error : "Connecct-PnpOnline : The sign-in name or password doesn ot match one in the Microsoft account system." Even Username and password correct then after it throws same error.
    – M Jain
    Commented Sep 3, 2021 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.