Credentials should not prompt while connectig SharePoint online

sns 7,241 Reputation points
2022-06-13T05:09:12.773+00:00

I have gone through following article, I am not certain which one is correct way to choose, my requirements are it should not prompt for credentials as per following screenshot rather script should take credentials itself & it should not contain plain text (highly secured) , is there any way to achieve this?

https://pnp.github.io/powershell/cmdlets/Connect-PnPOnline.html#examples

Interactive, use weblogin all these are prompting for credentials it should not be. Please help & PFA,

211543-image.png

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
5,990 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yi Lu_MSFT 16,586 Reputation points Microsoft Employee
    2022-06-13T08:02:25.817+00:00

    Hi @sns
    If you do not want to use the prompt and write user name and password in the command, you could use example 3:

    Connect-PnPOnline -Url "https://contoso.sharepoint.de" -ClientId 344b8aab-389c-4e4a-8fa1-4c1ae2c0a60d -ClientSecret $clientSecret  
    

    For more details, you could refer to this article and follow it step by step until "Using this principal with PnP PowerShell":
    https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.