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
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.