The Connect-MsolService cmdlet in PowerShell allows you to connect to Microsoft Azure Active Directory, this allows you to manage your Microsoft 365 settings from the command line. Often errors can occur in PowerShell if you are not using the correct syntax or do not have the correct modules installed or loaded.
If you are unable to use the Connect-MsolService cmdlet it is likely you are receiving the following error:
“connect-msolservice 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.”
In this post I am going to walk you through how to resolve to following error by installing the correct PowerShell module, or removing a corrupt PowerShell module.
What does this Connect-MsolService error mean?
This error means that you do not have the Connect-MSonline module loaded within your PowerShell session or the module is not installed. If you have installed the module in the past, it may be corrupt and require re-installation.
How to fix error The term 'Connect-MsolService' is not recognized
If you have installed the MSonline module in the past it is likely now corrupt and needs removing, start by deleting the MSOnline folder from the following location in your program files directory.
C:\Program Files\WindowsPowerShell\Modules\MSOnline
Otherwise follow the steps below to install the MSOnline PowerShell module:
- Open PowerShell as an administrator and run the following cmdlet
Install-Module MSOnline
2. Import the module to the current PowerShell session
Import-Module MSOnline
3. Use the Connect-MsolService cmdlet to establish a connection to Azure Active Directory
Connect-MsolService
4. You will then be prompted in a new window, to login with you Microsoft 365 username and password
You should now be fully authenticated to Azure Active Directory and no longer receiving the error when using the Connect-MsolService command!
Hello Daniel,
I´m really appreciate your time for this Topic
I had a lot of Problems and couldn’t find anything on the Internet.
Today i found your blog.
You really helped me.
Thank you so much.
Edu