Forum Discussion
Get-EXOMailbox -Filter returns empty when $WarningPreference = 'SilentlyContinue'
Get-EXOMailbox -Filter returns empty when $WarningPreference = 'SilentlyContinue' under UAMI app-only auth
Module version: ExchangeOnlineManagement 3.x (PS7, Azure Automation sandbox)
Auth method: Connect-ExchangeOnline -ManagedIdentity -ManagedIdentityAccountId <UAMI ClientId>
Reproduction steps:
$WarningPreference = 'SilentlyContinue'
Connect-ExchangeOnline -ManagedIdentity `
-ManagedIdentityAccountId "<UAMI-ClientId>" `
-Organization "yourtenant.onmicrosoft.com" `
-ShowBanner:$false
# Returns empty — mailbox provably exists
Get-EXOMailbox -Filter "ExternalDirectoryObjectId -eq '<EntraOID>'"
# Restore and retry — returns correctly
$WarningPreference = 'Continue'
Get-EXOMailbox -Filter "ExternalDirectoryObjectId -eq '<EntraOID>'"
Expected: Mailbox object returned regardless of $WarningPreference
Actual: Returns $null when $WarningPreference = 'SilentlyContinue'
Notes:
- Only affects -Filter parameter under app-only/UAMI auth
- -Identity and -UserPrincipalName are not affected
- Delegated auth sessions are not affected
- $WarningPreference = 'SilentlyContinue' is a common pattern in Azure Automation runbooks, making this a significant undocumented breaking behaviour for automation scenarios
1 Reply
I am not able to reproduce this, either by setting $WarningPreference = 'SilentlyContinue' or using the
-WarningAction parameter. In any case, if you are able to reliably reproduce this, open a support ticket.