Skip to content

/errors/exchange-online/get-mailbox-not-recognized

The term 'Get-Mailbox' is not recognized as the name of a cmdlet (Exchange Online PowerShell)

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
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.

powershell
Connect-ExchangeOnline -UserPrincipalName admin@contoso.com
Get-Mailbox -Identity user@contoso.com

Reproduce it

Import the module (3.10.1 here) without connecting and call Get-Mailbox:

powershell
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:

CauseHow to checkFix
Missing RBAC roleGet-ManagementRole -Cmdlet Set-Mailbox lists the roles that contain the cmdletGet a role group with that role assigned (for example Recipient Management), then reconnect
-CommandName usedLook at the connect command in the scriptRemove -CommandName or add the cmdlet to it
-Prefix usedGet-Command *Mailbox lists the real namesCall 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.

Sources