SharePoint PNP connect online giving argument error

sns 9,241 Reputation points
2022-02-24T15:47:59.317+00:00

I have tried to connect SharePoint online site using SHarePoint online mangement shell using -useweblogin method but giving attached error. Please help
it is working if I use tag interactive but I dont want to use as it security issue.177592-capture.png

we dont want to hard coded the user name and password in the script, which is the best way to secure credentials in the script.

Please help on this.

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

Accepted answer
  1. Echo Du_MSFT 17,266 Reputation points
    2022-02-25T02:45:41.283+00:00

    Hi @sns ,

    First I need to explain

    Connect-PnPOnline -Url "https://contoso.sharepoint.com" -UseWebLogin  
    

    "-UseWebLogin" to connect to SharePoint using legacy cookie based authentication. Note that this type of authentication is limited in its functionality. Cookies typically expire within a few days, if you use -UseWebLogin within that time a popup will appear which will disappear immediately, as expected.

    Therefore, we would recommend using "-Interactive"

    Connect-PnPOnline -Url "https://contoso.sharepoint.com" -Interactive  
    

    Of course, you can also run the following commands:

    $SiteURL = "https://domain.sharepoint.com/sites/sitename"   
     Connect-PnPOnline -Url $SiteURL -SPOManagementShell -ClearTokenCache  
    

    177722-1.jpg

    Reference:

    Thanks,
    Echo Du

    =====================================

    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.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.