Hi Everyone this is Prem, I have worked as M365 Support Ambassador. In this blog I will share How to Fix The term ‘Get-Mailbox’ is not recognized as the name of a cmdlet, function, script file, or operable program Error when using PowerShell.
This Error occurs when we try to run an Exchange command in PowerShell without connecting it to Exchange Online.
To fix this error we will first have to connect the PowerShell to exchange online and then run the required command.
Steps to fix The term ‘Get-Mailbox’ is not recognized as the name of a cmdlet, function, script file, or operable program Error:
Search for windows PowerShell and then run it as an administrator:

It should look like this:

Now connect to Exchange online using the PowerShell Opened with the steps above, run the following command:
Install-Module -Name ExchangeOnlineManagement
Allow permission to install by typing A and hit Enter, After that run:
Import-Module -Name ExchangeOnlineManagement
If you get error that running script is disabled or other error when running the first Install command, then run the below command and after that run the above Install and Import commands again:
Set-ExecutionPolicy unrestricted -scope currentuser
Allow it to set the execution policy if prompted by entering either A or Y.
Install-Module -Name ExchangeOnlineManagement
Import-Module -Name ExchangeOnlineManagement
Once the above commands completes without any error then run the below command to connect to Exchange Online:
Connect-ExchangeOnline

Enter your Global or Exchange Admin email address & password when prompted and it should get connected to Exchange Online on the PowerShell:

Once it is connect you can then run the Get-Mailbox command which you wanted and it should be able to bring the Output without any error.
Date:28/02/2023
Author: Prem
Tags: The term ‘Get-Mailbox’ is not recognized