The remote server returned an error (401) Unauthorized SharePoint online management shell error

In this SharePoint online error we will discuss how to resolve the error: Connect-SPOService : The remote server returned an error: (401) Unauthorized. The remote server returned an error (401) Unauthorized SharePoint online management shell error.

Recently while working with SharePoint online management shell we got the below error which says:

Connect-SPOService : The remote server returned an error: (401) Unauthorized.
At line:2 char:1
+ Connect-SPOService -Url http://onlysharepoint2013-admin.sharepoint.com/ -credent …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-SPOService], WebException
+ FullyQualifiedErrorId : System.Net.WebException,Microsoft.Online.SharePoint.PowerShell.ConnectSPOService

Get-SPOSite : No connection available. Use Connect-SPOService before running this CmdLet.
At line:3 char:1
+ Get-SPOSite
+ ~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-SPOSite], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.Online.SharePoint.PowerShell.GetSite

We were connecting to SharePoint online site using SharePoint online management shell.

Below was the command we were trying.

Import-Module Microsoft.Online.SharePoint.Powershell -Verbose
Connect-SPOService -Url http://onlysharepoint2013-admin.sharepoint.com/ -credential [email protected]
Get-SPOSite

The remote server returned an error (401) unauthorizedThe remote server returned an error (401) unauthorized

We were giving the -admin site also in the Url parameter, but still, the issue was coming.

The remote server returned an error (401) Unauthorized

We found out that the URL was creating the issue. we were providing http://onlysharepoint2013-admin.sharepoint.com/ (with http not with https)

We need to provide the URL as https URL. Office 365 URLs are always https.

So we replace the URL like https://onlysharepoint2013-admin.sharepoint.com/

You may like following PowerShell SharePoint tutorials:

This resolved the issue. We did not receive any The remote server returned an error: (401) Unauthorized error.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>