Share via

NotAbleToConnectSPOnlinePowerShell

sns 9,251 Reputation points
2021-12-10T15:18:37.353+00:00

I am tryign to connect SPOservice to connect sharepoint online admin url and further sharepoint sites. I tried using global admin and sharepoint online admin but no luck
And giving following error. Please help
156956-image.png

Microsoft 365 and Office | SharePoint | For business | Windows

Answer accepted by question author

Yi Lu_MSFT 17,701 Reputation points
2021-12-16T10:02:47.7+00:00

Hi @sns
This case is a bit stange and I could not reproduce it, as a workaround, if you are going to connect to a SharePoint Online site, you can use the PnP cmdlet Connect-PnPOnline. For example:

1.Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/yoursitename  

If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Yi Lu_MSFT 17,701 Reputation points
    2021-12-13T02:44:39.787+00:00

    Hi @sns
    First you could check if this account is a global administrator: Without SharePoint Online global administrator role, it is not feasible to run SharePoint Online management shell, in this case you could refer to:
    https://answers.microsoft.com/en-us/msoffice/forum/all/connect-sposervice-webexception-401-unauthorized/c3b68bf3-2c3f-44b6-8072-b0e0bd9c699d

    What's more, you could try using below commands:

    $adminUPN="<the full email address of a SharePoint administrator account, example: ******@contosotoycompany.onmicrosoft.com> "  
    $orgName="<name of your Office 365 organization, example: contosotoycompany>"  
    $userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."  
    Connect-SPOService -Url https://$orgName-admin.sharepoint.com  -Credential $userCredential  
    

    which you could refer to:
    https://social.technet.microsoft.com/Forums/en-US/c0a4bda2-0e82-4400-8055-9c78c40bb01e/connectsposervice-returns-401-unauthorized-but-i-am-global-administrator?forum=onlineservicessharepoint


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.