In some cases, you may find yourself staring at the following error message after running EXO PowerShell scripts:

Write-ErrorMessage :
  Ex6F9304|Microsoft.Exchange.Configuration.Tasks.ManagementObjectNotFoundException | 
  The operation couldn't be performed because object 'lene.hov' couldn't be found on
At C:\Users\Skrubbeltrang\AppData\Local\Temp\tmpEXO_gxzlxbbf.n1f\tmpEXO_gxzlxbbf.n1f.psm1:1188
+             Write-ErrorMessage $ErrorObject
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  + CategoryInfo          : NotSpecified: (:) [Get-Mailbox], ManagementObjectNotFoundException
  + FullyQualifiedErrorId : [Server=AS8PR09MB4727,RequestId=abb35ae7-d4c5-a0f5-55cb-c67305c96e40,
    TimeStamp=Thu, 14 Sep 2023 21:47:58 GMT],Write-ErrorMessage

Exchange Online EXO PowerShell scripting is a powerful tool for bulk editing, reporting, and automation. But let’s face reality: It sucks for ad-hoc first-level user support!

Firing up a PowerShell console to do daily user management tasks is far from optimal.

For stuff like calendar permission management, auto-reply scheduling, and Outlook automapping of shared mailbox, you’re far better off with an intuitive GUI:

What’s Up With ManagementObjectNotFoundException?

This error message indicates that whatever command you issued was not aimed at a valid object ID.

Take a closer look at the user ID and verify that it’s a valid identity.

For Get-Mailbox and similar CmdLets, you can use the following properties as Identity:

  • Name
  • Alias
  • Distinguished name (DN)
  • Canonical DN
  • Domain\Username
  • Email address
  • GUID
  • LegacyExchangeDN
  • SamAccountName
  • User ID or user principal name (UPN)

If, e.g., you want to retrieve the mailbox of a user, you can grab the Object Guid of the user and use it as input for the EXO CmdLet:

PS C:\> Connect-MgGraph -scope user.readwrite.all
Welcome To Microsoft Graph!
PS C:\> Get-MgUser -UserId | fl displayName,Id

DisplayName : Lene Hau
Id          : 97d3bc7f-8ee6-4974-9115-c33087ad5600

PS C:\> Get-Mailbox 97d3bc7f-8ee6-4974-9115-c33087ad5600

Name                      Alias           Database                       ProhibitSendQuota
----                      -----           --------                       -----------------
Lene Hau                  lene.hau        EURPR09DG188-db035             99 GB (106,300,44... 

If you still get the ManagementObjectNotFoundException error message, the user surely doesn’t have an Exchange Online mailbox.