Errors when connecting to SharePoint Online Management Shell

Symptoms

When you try to connect to SharePoint Online Management Shell, you receive one of the following error messages:

The remote server returned an error: (429)

The response status code is 'Unauthorized'

Connection disconnected: Unexpected error occurred

No connection available

Connect-SPOService : Could not connect to SharePoint Online.

Resolution

  1. Make sure that SharePoint Online Management Shell is up-to-date. For the steps to do this, see Getting started with SharePoint Online Management Shell.

  2. Verify that you're using the latest TLS protocols. For more information, see the following articles:

  3. Run PowerShell in administrative mode:

    1. Select Start, and then enter powershell in the search box.

    2. In the search results. look for Windows PowerShell or simply PowerShell (if you're using PowerShell Core).

    3. Right-click Windows PowerShell (or PowerShell), and select Run as administrator.

  4. After PowerShell is running in administrative mode, update the execution policy of the session by running the following command:

    Set-ExecutionPolicy Undefined
    
  5. Connect to the SharePoint Admin URL that you're using by running the following command:

    Connect-SPOService -Url https://contoso-admin.sharepoint.com  
    

    Note: In this command, replace https://contoso-admin.sharepoint.com with the URL of the SharePoint site that you're administrating.

References

For more information about SharePoint Online Management Shell, see the following articles:

Getting started with SharePoint Online Management Shell.

Cannot force Modern Authentication when using Connect-SPOService cmdlet in SharePoint Online Management Shell

Still need help? Go to SharePoint Community.