About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
When PowerShell answers "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.", it could not find a command with that name in the session. Microsoft's page for this message gives one cause: the module that provides the command "isn't loaded correctly".
Read the spelling first, then ask PowerShell what is loaded and what is available. Those checks only read. The fixes load or install a module, and each comes with its way back.
What the error means
Microsoft's page "Error when you try to run Azure Active Directory module for Windows PowerShell cmdlets: The term <cmdlet name> is not recognized" (dated 2026-01-15) shows the full message and the CommandNotFoundException that goes with it, with the category ObjectNotFound. It states the cause for its case: "This issue can occur if the Azure Active Directory module for Windows PowerShell isn't loaded correctly." It is written for that module only. Microsoft's pages give no list of other modules that produce the same message for the same reason, so treat the module cause as the lead to test, not as a proven fact for your command.
Microsoft's Exchange Online connection page shows the same message for another reason. REST-based connections to Exchange Online PowerShell "require the PowerShellGet module", and PowerShellGet in turn requires the PackageManagement module. Without both, you get errors such as "The term 'Update-ModuleManifest' is not recognized as the name of a cmdlet, function, script file, or operable program."
Two facts from Microsoft's Import-Module page decide how a module becomes available. Starting in PowerShell 3.0, "installed modules are automatically imported to the session when you use any commands or providers in the module", and you can turn that off with the $PSModuleAutoLoadingPreference variable. The module path page says PowerShell searches each folder listed in $Env:PSModulePath for module files, and that a problem with that variable can break autoloading.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| The command name is misspelt | The message names a term that is not a real cmdlet | Get-Command -Name <name> does not list a command of that name; compare the spelling with the module's documentation |
| The module is not installed | The message names a cmdlet from a module you expect | Get-Module -ListAvailable does not list the module |
| The module is installed but not loaded in this session | The cmdlet works in another window | Get-Module does not list it; Get-Module -ListAvailable does |
| The module's folder is not on the module path, or automatic loading is switched off | A module present on disk is not found | $Env:PSModulePath lacks the folder; $PSModuleAutoLoadingPreference is changed |
| A module the connection needs is missing (PowerShellGet or PackageManagement) | The missing term is Update-ModuleManifest during an Exchange Online connect |
Get-Module -ListAvailable -Name PowerShellGet, PackageManagement |
Prove the cause before changing anything
All of these only read. Run them in the window that shows the error. Replace <name> with the term from the message, written exactly as PowerShell printed it.
Get-Command -Name <name>
Get-Module
Get-Module -ListAvailable
$Env:PSModulePath
$PSVersionTable
Microsoft's Get-Module page says that without parameters Get-Module lists modules imported into the current session, and that -ListAvailable lists "the modules that are available to be imported from the paths specified in the PSModulePath environment variable". Microsoft's Azure Active Directory page tells you to run Get-Module and check that the MSOnline module is present.
If the module is in the -ListAvailable list but not in the plain Get-Module list, it is installed and not loaded. If it is in neither, it is not installed or not on the module path.
Example (illustrative): at contoso.com.au an administrator on app01 types Connect-MsolService and gets the message. Get-Module shows no MSOnline module and Get-Module -ListAvailable does not list it either. The module is not installed on app01, so importing it will not help. Installing it is the step that applies.
Fix
Match the fix to the row you proved.
Spelling or path
Microsoft's message says to check the spelling of the name and, if a path was included, to verify the path. Correct the name in the command and run it again. Nothing is changed on the computer.
The module is installed but not loaded
Before you change it, record what is loaded now:
Get-Module
Risk: the next command loads the module into this PowerShell session. Microsoft's Import-Module page says it imports "only into the current session", so nothing is saved for later sessions.
Import-Module <module-name>
Microsoft's Azure Active Directory page uses Import-Module MSOnline for its module. Then run the command that failed. To undo it, close the PowerShell window; the module is not loaded in the next session unless a command that needs it autoloads it.
The module is not installed
Microsoft's Azure Active Directory page says to install the module if it is not installed, and refers to its own installation page for that module. For a module from the PowerShell Gallery, the pattern is the Install-Module cmdlet, which on Windows PowerShell 5.1 needs, according to Microsoft's "Install a package manager for PowerShell" page, TLS 1.2 or higher and the latest PowerShellGet and PackageManagement.
Before you change it, record the modules installed now:
Get-InstalledModule
Risk: the next command downloads a module from the PowerShell Gallery and installs it. Microsoft's PowerShell Gallery overview says some of its packages are authored by Microsoft and others by the PowerShell community, so install only a module you have chosen. -Scope CurrentUser limits the install to your account.
Install-Module -Name <module-name> -Scope CurrentUser -Repository PSGallery
To undo it, run this only if the module was not in the list you recorded:
Uninstall-Module -Name <module-name>
Microsoft's Uninstall-Module page says you can't uninstall a module if other modules depend on it.
A connection needs PowerShellGet and PackageManagement
If the missing term is Update-ModuleManifest while connecting to Exchange Online, Microsoft's Exchange Online page says you need both the PowerShellGet and PackageManagement modules for REST-based connections and points to its PowerShellGet requirements page. Microsoft's "Install a package manager for PowerShell" page gives the update steps for Windows PowerShell 5.1: enable TLS 1.2, accept the NuGet provider, then install PowerShellGet from the Gallery. Those steps install modules and a NuGet provider, and Microsoft's pages give no uninstall step for the provider. The saved-list, Risk and undo steps for that update are in Install-Module "Unable to resolve package source" and "No match was found for the specified search criteria and module name", so follow them there and do not run the update from this section.
The module path
If the module exists on disk and Get-Module -ListAvailable does not show it, compare the folder with $Env:PSModulePath. Microsoft's page says the variable is built each time PowerShell starts and that PowerShell searches each folder in it. The page describes machine-scoped and user-scoped values of the variable. Microsoft's pages give no step-by-step change, so ask the owner of the server image before editing it.
Compare a working computer with the failing one
Microsoft's Exchange Online page makes two points that apply to any server where this message appears after a connection attempt. First, Microsoft's step 1 loads the module by name with Import-Module ExchangeOnlineManagement, and its note says that if the module is already installed, "you can typically skip this step and run Connect-ExchangeOnline without manually loading the module first". Second, REST-based connections need both PowerShellGet and PackageManagement, so if the same connection works on one computer and fails on another, compare Get-Module -ListAvailable on both before you change either. Nothing in those two checks changes a computer.
Confirm the fix
- Run
Get-Command -Name <name>; it should return the command and the module that provides it. - Run the command that failed. The message should not appear.
- Open a new PowerShell window and run the command again. If it works without
Import-Module, autoloading found the installed module, which is what Microsoft's page describes for PowerShell 3.0 and later.
What to watch afterwards
- Scripts that rely on a module being loaded. A scheduled script run as another account has its own module paths and its own CurrentUser installs.
- The PowerShell version used by the script. The module path page describes PowerShell 7 folders, and Windows PowerShell uses different logic, which the page also describes.
- A module installed with
-Scope CurrentUser, which Microsoft says is accessible only to that user.
Read next
Related articles you may want next.
- TroubleshootingInstall-Module "Unable to resolve package source" and "No match was found for the specified search criteria and module name"Install-Module says Unable to resolve package source, then No match was found. Enable TLS 1.2 in the session, then update PowerShellGet, with a way back.Read article
- TroubleshootingPowerShell "running scripts is disabled on this system": find which execution policy is blocking the scriptPowerShell says running scripts is disabled on this system. List the execution policy in every scope, then change the narrowest scope with a way back.Read article
- TroubleshootingMicrosoft Graph PowerShell "Authorization_RequestDenied. Insufficient privileges to complete the operation."Microsoft Graph PowerShell returns Authorization_RequestDenied. Compare Get-MgContext scopes with Find-MgGraphCommand, then add the missing scope.Read article
Risks and limits
These commands have not been run or lab-tested.
Microsoft's error page names one module, MSOnline, and one cause. It does not say that every "not recognized" message is a module problem: a misspelt name, a command that does not exist on that PowerShell version, or a program that is not on the path produces the same words. The module path page describes PowerShell 7 locations and says Windows PowerShell builds its path by its own logic, so check your own $Env:PSModulePath. Microsoft's pages give no list of which modules work in which PowerShell version.
Sources
- Error when you try to run Azure Active Directory module for Windows PowerShell cmdlets: The term <cmdlet name> is not recognized — Microsoft Learn, page dated 2026-01-15, accessed 22 November 2026
- Connect to Exchange Online PowerShell — Microsoft Learn, page dated 2025-07-11, accessed 22 November 2026
- Import-Module — Microsoft Learn, date not shown, accessed 22 November 2026
- Get-Module — Microsoft Learn, date not shown, accessed 22 November 2026
- Get-Command — Microsoft Learn, date not shown, accessed 22 November 2026
- about_PSModulePath — Microsoft Learn, page dated 2026-08-25, accessed 22 November 2026
- Install a package manager for PowerShell — Microsoft Learn, page dated 2026-01-27, accessed 22 November 2026
- PowerShellGet and the PowerShell Gallery — Microsoft Learn, page dated 2026-01-27, accessed 22 November 2026
- Install-Module — Microsoft Learn, date not shown, accessed 22 November 2026
- Uninstall-Module — Microsoft Learn, date not shown, accessed 22 November 2026
- Get-InstalledModule — Microsoft Learn, date not shown, accessed 22 November 2026
This article was originally published on .