anyone knows a solution for Connect-SPOService on SharePoint Online PowerShell.

So I need to use Set-SPOSite and before I can use that I need to do Connect-SPOService first.

PS C:\WINDOWS\system32> Connect-SPOService

cmdlet Connect-SPOService at command pipeline position 1
Supply values for the following parameters:
Url: https://test.sharepoint.com/sites/test/
Connect-SPOService : Could not authenticate to SharePoint Online https://test.sharepoint.com/sites/test/
using OAuth 2.0
At line:1 char:1
+ Connect-SPOService
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-SPOService], AuthenticationException
    + FullyQualifiedErrorId : Microsoft.Online.SharePoint.PowerShell.AuthenticationException,Microsoft.Online.SharePoi

The URL is not real, I login normally and did my 2FA with SMS but when I submit my 2FA it always fail. I tried it like 5 times just to be sure I was not putting the wrong code. I also tried using my App Password but it won't let me login with it.

Any known solution for this? My end goal is to edit my site to allow pages to be editted using SharePoint Designer. Would be a lot faster on editting ItemStyles for CQWP later

Set-SPOSite -Identity https://test.sharepoint.com/sites/test/ -DenyAddAndCustomizePages 0

3 Answers 3


Have you tried connecting to the '-admin' Url?


Connect-SPOService -Url https://contoso-admin.sharepoint.com -credential [email protected]

  • I tried that, now I'm getting Connect-SPOService : Current site is not a tenant administration site. which is weird cause I know I am a tenant administrator. Jun 18, 2018 at 18:13
  • You are tenant admin but may be the site url you are providing is a not a tenant admin site.
    – Deepmala
    Jun 19, 2018 at 3:19

It seems credentials you are providing are somehow not working.Try below:

$username = "[email protected]"
$password = "password"
$cred = New-Object -TypeName System.Management.Automation.PSCredential - 
argumentlist $userName, $(convertto-securestring $Password -asplaintext -force)
Connect-SPOService -Url https://contoso-admin.sharepoint.com/ -Credential 

 Connect-PnPOnline -Url $siteURL -Credentials $cred 
  • 1
    i find it a little odd that you have to connect to the admin site before connecting to any other site / object. does anyone have some background on this logic? Aug 14, 2019 at 16:46
  • Suggesting another PowerShell module doesn't seem particular useful. OP seems to need to use SPO, not PnP.
    – TylerH
    May 18, 2021 at 16:33

Just remove '/' at the end of url after test


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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