This Azure PowerShell article discusses how to resolve the error “connect-msolservice is not recognized.” That I got while executing the Connect-Msolservice PowerShell command.
Table of Contents
Connect-Msolservice is not recognized
Recently, I attempted to execute the Connect-MsolService PowerShell command to initiate a connection to my Azure Active Directory, but I encountered an error. You can see the screenshot below for your reference.

Below is the complete error message for your reference.
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, then run the below command in Windows PowerShell.
Solution
If you encounter this error, try the solutions below to resolve the issue.
Solution-1:
- To fix the error, open the Windows PowerShell command prompt in administrator mode

2. The next step is to run the following PowerShell cmdlet to install the MSOnline module
Install-Module -Name MSOnline
Click the “Yes” button in the above pop-up. Then click on the Yes to All button in the pop-up below.

You can fix the error. No match was found for the specified search criteria and module name ‘MSOnline’, in case you get the same error while installing the MSOnline PowerShell module.
After successful installation, you can execute the following command.
Import-Module MSOnline
$credentials = Get-Credential
connect-msolservice -Credential $CredentialNow, you can log in successfully with your credentials. Check out the screenshot below.

Note: Run the Windows PowerShell ISE in Run as Administrator mode, and then follow the steps above. Otherwise, you will encounter the same error.
Solution-2:
If the above solution didn’t work for you and you are still getting the same error, then try the steps below
Run the below PowerShell cmdlets in the same order, one after the other
uninstall-module AzureAD
install-module AzureAD
install-module AzureADPreview
install-module MSOnline
Import-Module MSOnline
$credentials = Get-Credential
connect-msolservice -Credential $CredentialThis will resolve the error, and you will be able to initiate a connection to your Azure AD with the connect-sol service PowerShell command successfully.
Video Tutorial
Final Thoughts
In this Azure PowerShell article, we discussed two methods to fix the error “Connect-MsolService not recognized.” I hope this information helps you.

I am Rajkishore, and I am a Microsoft Certified IT Consultant. I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machines, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.
