Credentials should not prompt while connectig SharePoint online

sns 7,241 Reputation points

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?

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


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

    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 "" -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":

    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.