How to sign out of SSO on PnP PowerShell for SP Online?

Ryan 191 Reputation points
2021-03-01T20:23:59.553+00:00

When I use PnP PowerShell, I use this to connect

Connect-PnPOnline -Url "https://xxxxxxxxx.sharepoint.com/sites/xxxxxxxxxx" -UseWebLogin

And normally this will give me a box to pick an account. However I reformatted my machine recently and now it's bypassing the option to pick a new account and just trying to sign in with some default account that won't have access and then throws an error. I'm looking for a way to sign out of that default account and let me enter in a new account.

I did some research and they say to first sign out using

Connect-PnPOnline -Url "https://xxxxxxxxxxx.sharepoint.com" -SPOManagementShell -ClearTokenCache;

I did this, but when I use the weblogin again, it again just tries to sign in with that same account.

I also opened IE and deleted all the cache and cookies. I went on that site manually and signed out there, but nothing worked.

I am on SharePointPnPPowerShellOnline 3.29.2101.0.

How can this be resolved?

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
11,069 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,201 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,629 questions
{count} votes

Accepted answer
  1. Ryan 191 Reputation points
    2021-03-05T00:56:54.887+00:00

    I seem to have figured it out using my version of PnP PowerShell. I went into windows Settings > Accounts > Email & accounts and added my other work accounts there.


2 additional answers

Sort by: Most helpful
  1. Echo Du_MSFT 17,216 Reputation points
    2021-03-02T09:24:44.76+00:00

    Hello @Ryan ,

    You can execute the following command:

    Connect-PnPOnline -Url "https://contoson.sharepoint.com/sites/echo" -Interactive  
    

    73327-1.png

    More information, please refer to this article.

    Thanks,
    Echo Du

    ====================
    Updated Answer ===================

    Hi @Ryan ,

    It is recommended that you better use the latest version of the PnP PowerShell Module.

    #Uninstall any edition of PnP PowerShell   
    Uninstall-Module -Name "SharePointPnPPowerShellOnline" -AllVersions -Force  
    #Install the new module:  
    Install-Module -Name "PnP.PowerShell"  
    

    Thanks,
    Echo Du

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

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    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 comments No comments

  2. Ryan 191 Reputation points
    2021-03-02T14:56:30.177+00:00

    I tried that, but that flag doesn't exist in the pnp powershell version I have

    SharePointPnPPowerShellOnline 3.29.2101.0

    I am on the legacy one still as I cannot run the new one due to permissions not granted. I would like to resolve it using this version for now.


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.