This Azure PowerShell article will discuss how to fix 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 was trying to execute the Connect-Msolservice PowerShell command to initiate a connection to my Azure Active Directory, But all of a sudden, I got this error. You can see the below screenshot 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.
Connect-Msolservice is not recognized [Solved]
If you are getting this error, you can try the solutions below to fix this issue.
Solution-1:
- To fix the error, open the Windows PowerShell command prompt in administrator mode
2. The next step is to run the below PowerShell cmdlet to install the MSOnline module
Install-Module -Name MSOnline
Click on the Yes button on the above pop-up. Then click on the Yes to All button from the below Pop-up.
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 successfully installation, you can execute the below command.
Import-Module MSOnline
$credentials = Get-Credential
connect-msolservice -Credential $Credential
Now, you can log in successfully with your credentials. Check out the screenshot below.
Note: Run the Windows PowerShell ISE with Run as Administrator mode and then follow the above steps. Otherwise, you will end up with 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 below steps
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 $Credential
This will fix this error, and you will be able to initiate the connection to your Azure AD with the connect-sol service PowerShell command successfully.
Connect-Msolservice not recognized – Video Tutorial
Final Thoughts
In this Azure PowerShell article, we discussed 3 methods to fix the error “Connect-Msolservice not recognized”. I hope this information will help you !!!
I am Rajkishore, and I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machine, 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.