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

The remote server returned an error (401) unauthorized
SharePoint deveopment training course

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 Bhawana@OnlySharePoint2013.onmicrosoft.com
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.

Check out Best Alternative to InfoPath -> Try Now

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

About Bhawana Rathore

Hello Everyone!! I am Bhawana a SharePoint MVP and having about 8+ years of SharePoint experience as well as in .Net technologies . I have worked in all the versions of SharePoint from wss to Office 365. I have good exposure in Customization and Migration using Nintex, Metalogix tools . Now exploring more in SharePoint 2016 :) Hope here I can contribute and share my knowledge to the fullest. As I believe "There is no wealth like knowledge, and no poverty like ignorance"

View all posts by Bhawana Rathore →