1

I'm a global admin on my O365 tenant. I get the below error when I try to access anything:

Exception calling "ExecuteQuery" with "0" argument(s): "Cannot contact web site
'https://domain.sharepoint.com/' or the web site does not support SharePoint Online credentials. The response
status code is 'Unauthorized'. The response headers are 'X-SharePointHealthScore=0,
SPRequestGuid=664da69d-002a-2000-15b5-db84f0677cb9, request-id=664da69d-002a-2000-15b5-db84f0677cb9,
X-MSDAVEXT_Error=917656; Access+denied.+Before+opening+files+in+this+location%2c+you+must+first+browse+to+the+web+site+
and+select+the+option+to+login+automatically., MicrosoftSharePointTeamServices=16.0.0.5708,
X-Content-Type-Options=nosniff, X-MS-InvokeApp=1; RequireReadOnly, Content-Length=0, Content-Type=text/plain;
charset=utf-8, Date=Thu, 22 Sep 2016 16:10:24 GMT, P3P=CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI
TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI", Server=Microsoft-IIS/8.5, X-Powered-By=ASP.NET'."
At line:1 char:1
+ $Context.ExecuteQuery()
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NotSupportedException
1

Try to set LegacyAuthProtocolsEnabled to false

Set-SPOTenant -LegacyAuthProtocolsEnabled $False

And don't use -credential parameter at Connect-SPOService , just type it as

Connect-SPOService -Url https://deletethis.sharepoint.com

Then provide username and password , execute your code that should be now worked without status code is 'Unauthorized' !

Check also Unable to access SharePoint Online with Powershell

  • So I dont think this worked. I want it set to False, not True...right? Anytime I try to run ExecuteQuery()...no matter what I'm doing....I get that error. It is supposed to be Tenant wide right? My error only points to my root site collection (see above) even though I'm running scripts on other ones. – Joe Fedorowicz Sep 22 '16 at 21:40
  • the above solution to overcome status code is 'Unauthorized' ? are you tried to connect as I mentioned above ?! – Mohamed El-Qassas MVP Sep 22 '16 at 22:33
  • It connects fine. It blocks me from pulling any data. – Joe Fedorowicz Sep 22 '16 at 22:57
  • Dear @JoeFedorowicz if it connects properly why it get status code is 'Unauthorized' !! – Mohamed El-Qassas MVP Sep 22 '16 at 22:59
  • That's what I'm asking dude – Joe Fedorowicz Sep 22 '16 at 23:00
0

In my case the issue was related to this parameter was set to True -

Command: Get-SPOTenant

LegacyAuthProtocolsEnabled : False

which should be :

LegacyAuthProtocolsEnabled : True

Command: Set-SPOTenant -LegacyAuthProtocolsEnabled $True

Note: You may be instantly able to see the newly changed value, but it takes about an hour to actually see the effect.

0

Once you have done the change at the Tenant level, it may take 24 hours for the change to be propagated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.