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 Microsoft email and calendaring hosted service.
6,171 questions
Windows for business Windows Server User experience PowerShell
{count} votes

Accepted answer
  1. Vasil Michev 119.5K 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 47,901 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 Answers by the question author, which helps users to know the answer solved the author's problem.