Hi Everyone this is Prem, I have worked as Microsoft 365 support ambassador. In this blog I will share how to Fix The term Connect-MsolService 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, error in PowerShell.
This error occurs when we try to connect to Microsoft 365 Admin center using PowerShell and it fails to recognize the Connect-MsolService command.
Connect-MsolService command is available in the PowerShell Module named MsOnline, We will first have to install the module to be able to run the connect command.
Steps to Install and Connect to Microsoft 365 admin Center using PowerShell:
Search for Windows PowerShell on the computer and Run it as administrator:
It should look like this:
Run this command:
Set-ExecutionPolicy RemoteSigned -scope CurrentUser
Type A and hit enter when asked.
Now we will run the command below in the PowerShell to install the Module which will help us to run the command Connect-MsolService later:
Install-Module -Name MsOnline -Scope CurrentUser
If you get the warning: You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
‘PSGallery’?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is “N”):
Type A and hit Enter.
Now run the following:
Import-Module MsOnline
Once import is completed run the below command to connect:
Connect-MsolService
Enter your Global Admin email address and password (Depending on the task to be performed on the PowerShell you can use different admin account as well).
In conclusion if you get The term Connect-MsolService is not recognized Error in Powershell then you will have to install the module first using the steps shown above to fix the error.
Date:27/02/2022
Author: Prem
Tags: Fix The term Connect-MsolService is not recognized Error
Pingback: You must call the Connect-MsolService cmdlet before calling any other cmdlets - The Admin 365