To run cmdlets on SharePointOnline, you first need to connect to the SPOService. If you don’t this error will return:
PS C:\> Get-SPOUser -Site https://itexperience-my.sharepoint.com -LoginName admin@itexperience.net | fl Get-SPOUser : No connection available. Use Connect-SPOService before running this CmdLet.At line:1 char:1+ Get-SPOUser -Site https://itexperience-my.sharepoint.com -LoginName a … + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-SPOUser], InvalidOperationException + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.Online.SharePoint.PowerShell.GetSPOUser
The error is pretty obvious. But to solve No connection available. Use Connect-SPOService before running this CmdLet , you must run Connect-SPOService which may lead to another bunch of errors 🙂
I’ve summed up the most common ones with their solutions:
Error 1:
PS C:\> connect-sposervice
connect-sposervice : The term ‘connect-sposervice’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Solution 1:
Download and install the SharePoint Online Management Shell from https://www.microsoft.com/en-us/download/details.aspx?id=35588 . After installation, re-open a Powershell window and try again
Error 2:
connect-sposervice : Could not authenticate to SharePoint Online
https://itexperience-my.sharepoint.com/personal/admin_itexperience_net/ using OAuth 2.0
Solution 2:
You obviously have filled in the wrong URL when prompted. You should only fill in the base URL, so in this case: https://itexperience-my.sharepoint.com . In addition, you should NOT point to the mysites, but to tenant.sharepoint.com. So: https://itexperience.sharepoint.com
Error 3:
Connect-SPOService: Current site is not a tenant administration site
Solution 3:
You have filled in a URL which is not of any tenant. Verify the tenant name. Don’t use https://tenant-my.sharepoint.com
Do you have another error related to SharePoint Online cmdlets? Let me know in the comments section!