/errors/exchange-online/get-mailbox-not-recognized
The term 'Get-Mailbox' is not recognized as the name of a cmdlet (Exchange Online PowerShell)
- tool
- Exchange Online PowerShell
- exit code
- 1
- versions
- ExchangeOnlineManagement 3.x
- os
- windows, linux, macos
The term 'Get-Mailbox' is not recognized as the name of a cmdlet, function, script file, or operable program. in Exchange Online PowerShell almost always means you have not connected yet. In the ExchangeOnlineManagement module (EXO V3), Get-Mailbox, Set-Mailbox and every other Exchange cmdlet are created by Connect-ExchangeOnline; Import-Module alone gives you only the connect cmdlets and the Get-EXO* cmdlets.
Connect-ExchangeOnline -UserPrincipalName admin@contoso.com
Get-Mailbox -Identity user@contoso.comReproduce it
Import the module (3.10.1 here) without connecting and call Get-Mailbox:
Import-Module ExchangeOnlineManagement
try {
Get-Mailbox -Identity user@contoso.com -ErrorAction Stop
} catch {
$_.Exception.Message
$_.FullyQualifiedErrorId
}
"Get-EXOMailbox exists offline: " + [bool](Get-Command Get-EXOMailbox -ErrorAction SilentlyContinue)Output
The term 'Get-Mailbox' 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. CommandNotFoundException Get-EXOMailbox exists offline: True
Get-EXOMailbox is part of the module itself, so it exists before you connect (and fails with You must call Connect-ExchangeOnline instead).
It still happens after connecting
When Connect-ExchangeOnline succeeded but one cmdlet is missing, the connection did not import it:
| Cause | How to check | Fix |
|---|---|---|
| Missing RBAC role | Get-ManagementRole -Cmdlet Set-Mailbox lists the roles that contain the cmdlet | Get a role group with that role assigned (for example Recipient Management), then reconnect |
| -CommandName used | Look at the connect command in the script | Remove -CommandName or add the cmdlet to it |
| -Prefix used | Get-Command *Mailbox lists the real names | Call the prefixed name, for example Get-ContosoMailbox |
Exchange Online imports only the cmdlets and parameters that your roles allow, so a missing role shows up as "not recognized" (for a cmdlet) or "A parameter cannot be found" (for a parameter), not as "access denied". Role changes apply to new connections: run Disconnect-ExchangeOnline and connect again after a role is assigned.