1

I am unable to connect to SPO from SharePoint online management shell using my account. MFA is enabled.

I'm executing the following command:

Connect-SPOService -url https://[URL].sharepoint.com

And I get the following response:

Connect-SPOService : Could not authenticate to SharePoint Online 
https://[URL].sharepoint.com/ using OAuth 2.0
    At line:1 char:1
    + Connect-SPOService -url https://[URL].sharepoint.com
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Connect-SPOService], AuthenticationException
    + FullyQualifiedErrorId : Microsoft.Online.SharePoint.PowerShell.AuthenticationException,Microsoft.Online.SharePoi
    nt.PowerShell.ConnectSPOService

Can anyone help with this?

Thanks.

0

Try following below Steps:

  1. Open SharePoint Online management shell using Run as administrator.
  2. Then try using below code:
    $UserName = "adminUser@domain.onmicrosoft.com"
    $SPOAdminCenterUrl = "https://domain-admin.sharepoint.com"

    $O365Cred = Get-Credential -UserName $UserName
    Connect-SPOService -Url $SPOAdminCenterUrl -Credential $O365Cred

Note: I have used URL of SharePoint Online Administration Center and not any other SharePoint site.

As per the official documentation by Microsoft,

Connect-SPOService Connects a SharePoint Online global administrator to a SharePoint Online connection (the SharePoint Online Administration Center). This cmdlet must be run before any other SharePoint Online cmdlets can run.

You must be a SharePoint Online global administrator to run the cmdlet.

You can read more about permissions, signle PowerShell session per Windows and parameters of this command using above link of official documentation.

0

Connect-SPOService works on the yoursharepoint-admin.sharepoint.com sites. You need to be have access to that site which means you should have administration rights on SharePoint in your subscription. Only then you will be able to connect to the sites.

Connect-SPOService -url https://yourorgname-admin.sharepoint.com

After hitting this, it will prompt for user/password and MFA. If you are not a global administrator and still want to connect to your site, you can try using PnPOnline cmdlets given below.

Install-Module SharePointPnPPowerShellOnline

This will install the PnP module and then SharePoint Online PnP cmdlets will be available for use. Hit the below cmdlet to connect to your site.

Connect-PnPOnline -Url https://yoursite.sharepoint.com -UseWebLogin

This will open a browser dialogue for your user/password and MFA. Here is the reference link from MSDN.

0

Run SharePoint Online Management Shell with system account.

For this commend: Connect-SPOService -url https://[URL].sharepoint.com, We must use URL of SharePoint Online Administration Center and not any other SharePoint site.

Getting started with SharePoint Online Management Shell:

https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-online/connect-sharepoint-online?view=sharepoint-ps

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.