Exchange Online PowerShell filter bug

D.M 20 Reputation points
2024-05-16T15:17:49.7766667+00:00

The Exchange Online PowerShell module seems to have a bug within the -Filter argument for Get-Mailbox. Specifically with the AuditEnabled property of a mailbox. I've tried the following:

Get-Mailbox -Filter 'AuditEnabled -eq $False'

Get-Mailbox -Filter "AuditEnabled -eq 'False'"

They don't seem to work though:

PosH-ExchangeBug

Using double quotes like Get-Mailbox -Filter "AuditEnabled -eq $False" just throws an error for invalid filter syntax so that's not it. Anyone seen this before?

Exchange Online
Exchange Online
A cloud-based service included in Microsoft 365, delivering scalable messaging and collaboration features with simplified management and automatic updates.
Windows for business | Windows Server | User experience | PowerShell
{count} votes

Answer accepted by question author
  1. Vasil Michev 123.7K Reputation points MVP Volunteer Moderator
    2024-05-16T16:03:50.0966667+00:00

    The issue is not with the filter, but the property itself. A while back, Microsoft changed how this works in Exchange Online, where auditing is now enabled by default on the org level (and this overrides the per-user setting). Quote from the official documentation:

    When mailbox auditing on by default is turned on for the organization, the AuditEnabled property for affected mailboxes won't be changed from False to True. In other words, mailbox auditing on by default ignores the AuditEnabled property on mailboxes.

    Details are here: https://learn.microsoft.com/en-us/purview/audit-mailboxes

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Rich Matheisen 48,026 Reputation points
    2024-05-16T15:44:44.9566667+00:00

    Try "AuditEnabled -eq `$False"

    See: https://learn.microsoft.com/en-us/powershell/exchange/recipient-filters?view=exchange-ps#additional-opath-syntax-information

    • System values: Don't enclose system values (for example, $true, $false, or $null). To enclose the whole OPATH filter in double quotation marks, you need to escape the dollar sign in system value (for example, `$true).

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.