Connect-Msolservice is not recognized

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.

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.

the term connect-msolservice is not recognized

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:

  1. To fix the error, open the Windows PowerShell command prompt in administrator mode
connect-msolservice is not recognized as the name of a cmdlet

2. The next step is to run the following PowerShell cmdlet to install the MSOnline module

Install-Module -Name MSOnline
connect-msolservice is not recognized command

Click the “Yes” button in the above pop-up. Then click on the Yes to All button in the pop-up below.

powershell connect-msolservice is not recognized

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 $Credential

Now, you can log in successfully with your credentials. Check out the screenshot below.

connect-msolservice is not recognized powershell 7

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 $Credential

This 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.

Azure Virtual Machine

DOWNLOAD FREE AZURE VIRTUAL MACHINE PDF

Download our free 25+ page Azure Virtual Machine guide and master cloud deployment today!