Fix : The term ‘Connect-SPOService’ is not recognized as the name of a cmdlet

Problem :

I have got the error message “The term ‘Connect-SPOService’ is not recognized as the name of a cmdlet” when I run the powershell cmdlet Connect-SPOService to connect SharePoint Online site.

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.
At line:1 char:1
+ Connect-SPOService -url https://conotoso-admin.sharepoint.com
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Connect-SPOService:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Solution :

The command Connect-SPOService belongs to SharePoint Online Management Shell, so before using this command we need to install the SPO Management Shell and import the module. You only need to install once for each computer from which you are running SPO Powershell commands. Multiple installations also make the problem to run the command Connect-SPOService and Import-Module.

Install SharePoint Online Management Shell:

You can install the SharePoint Online Management Shell by running the following command in administrative mode (Run as administrator).

Install-Module Microsoft.Online.SharePoint.PowerShell -Force

You can also download and install the setup from this path: Download SharePoint Online Management Shell

Connect SharePoint Online Module:

Once you have installed the above setup, run the following command to import the SharePoint Online Powershell module.

Import-Module Microsoft.Online.SharePoint.Powershell

Then run the following commands to connect spo service and list all sites.

Connect-SPOService -url https://conotoso-admin.sharepoint.com 
Get-SPOSite | Select Title, Url

Fix – Import-Module : Could not load type Microsoft.SharePoint.Administration.DesignPackageType:

You might have still face issue to import SPO module and run Connect-SPOService command even after installing the required Powershell module.

You might have received the below error message while trying to import the SharePoint Online Powershell module with “Import-Module -Name Microsoft.Online.SharePoint.PowerShell”.

PS C:\WINDOWS\system32> Import-Module Microsoft.Online.SharePoint.Powershell
Import-Module : Could not load type 'Microsoft.SharePoint.Administration.DesignPackageType' from assembly
'Microsoft.SharePoint.Client, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.
At line:1 char:1
+ Import-Module Microsoft.Online.SharePoint.Powershell
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], TypeLoadException
    + FullyQualifiedErrorId : System.TypeLoadException,Microsoft.PowerShell.Commands.ImportModuleCommand

This problem may occurred due to assembly version mismatch or multiple installation of the SharePoint Online Management Shell/SharePoint Online Client SDK . To resolve the problem, we have to completely uninstall SPO Management Shell and SPO Client SDK and install the latest SPO Powershell module. Follow the below steps:

  • Open Control Panel -> UnInstall Programs -> Search for SharePoint related setups.
  • Locate SharePoint Client Components -> Uninstall.
  • Locate SharePoint Online Management Shell -> Uninstall.
  • Ensure that anyone of the above setup is installed more than one time. If so, remove all the instances.
  • Now, open the Powershell console in administrative mode (Run as administrator).
  • Uninstall SPO Powershell module (If already exists) by running this command: Uninstall-Module -Name Microsoft.Online.SharePoint.PowerShell -AllVersions -Force
  • Finally, install the latest SPO Powershell module by running this command: Install-Module Microsoft.Online.SharePoint.PowerShell -Force


Advertisement

Leave a Comment