Problem to enable audit log on Public Folder Mailboxes via PowerShell command

Copper Contributor

Hi all,

 

I am trying to enable the audit logs for the Public Folder Mailbox via the PowerShell command following MS recommendation, but I am getting an error. Does anyone know what am I doing wrong? 

This is part of improving our Microsoft Secure Score in the M365 task.

 

 

Get-Mailbox -PublicFolder | Set-Mailbox -AuditEnabled $true

 

 

 

Error:

PS C:\Users\user> Get-Mailbox -PublicFolder | Set-Mailbox -AuditEnabled $true
Write-ErrorMessage : Ex6F9304|Microsoft.Exchange.Configuration.Tasks.ManagementObjectNotFoundException|The operation couldn't be performed because object 'Production Public Folder' couldn't be found on 'CWLP123XXXXXXXX.GBRP123A008.PROD.OUTLOOK.COM'.
At C:\Users\user\AppData\Local\Temp\tmpEXO_0ca3pqh4.fx2\tmpEXO_0ca3pqh4.fx2.psm1:1190 char:13
+             Write-ErrorMessage $ErrorObject
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Production Public Folder:MailboxIdParameter) [Set-Mailbox], ManagementObjectNotFoundException
    + FullyQualifiedErrorId : [Server=LO6P1XXXXXXXX,RequestId=e8bd38c9-5212-e0a6-6f10-9a05xxxxxxxx,TimeStamp=Thu, 02 Nov 2023 10:39:00 GMT],Write-ErrorMessage

 

 

 

PS C:\Users\tzanardo> Get-Mailbox -PublicFolder 

Name                      Alias           Database                       ProhibitSendQuota    ExternalDirectoryObjectId                                                                           
----                      -----           --------                       -----------------    -------------------------                                                                           
Production Public Folder   ProductionPubl... GBRP123DGxxxxxxxx             99 GB (106,300,44...                                     

 

 

Thanks

T

5 Replies

@tcz87 

 

Hi, T.

 

Having a read of the documentation, you need to include the -PublicFolder parameter in the Set-Mailbox commandlet:

 

 

Cheers,

Lain

Hi @LainRobertson 

 

I tried to run this and it keeps failing :sad:

 

PS C:\Users\user> Get-Mailbox -PublicFolder | Set-Mailbox -PublicFolder -AuditEnabled $true
Write-ErrorMessage : |Microsoft.Exchange.Configuration.Tasks.ThrowTerminatingErrorException|Parameter 'AuditEnabled' is not valid when parameter 'PublicFolder' is specified.



PS C:\Users\user> Get-Mailbox -PublicFolder | Set-Mailbox -PublicFolder | Set-Mailbox -AuditEnabled $true
WARNING: The command completed successfully but no settings of 'Production Public Folder' have been modified.

 

@tcz87 

 

Hi, T.

 

That error appears to be correct, as auditing is not supported on resource or public folder mailboxes:

 

 

Cheers,

Lain

@LainRobertson 

 

Something is not correct then. I am working on improving our Microsoft Secure Score and this is what I am on at the moment:


tcz87_0-1699442271074.png

 

Not sure what I need to do next.

@tcz87 

 

Hi, T.

 

I'm no Exchange Online expert but it seems either the advice in that message is bad, or the ExchangeOnlineManagement module simply doesn't support that functionality yet - I have no idea which of those two is true (if any are).

 

The error from Set-Mailbox is quite clear, and I've confirmed as much myself from a quick test.

 

Enabling auditing on a resource mailbox (in my test, I used a room mailbox) works fine. However, it fails as per your previous posts when trying the same thing on a public folder mailbox.

 

Someone with more Exchange Online knowledge might know of a way, but from the documentation and brief testing, I cannot see a way.

 

Cheers,

Lain