Forum Discussion
tcz87
Nov 02, 2023Copper Contributor
Problem to enable audit log on Public Folder Mailboxes via PowerShell command
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
- LainRobertsonSilver Contributor
Hi, T.
Having a read of the documentation, you need to include the -PublicFolder parameter in the Set-Mailbox commandlet:
Cheers,
Lain
- tcz87Copper Contributor
I tried to run this and it keeps failing

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.- LainRobertsonSilver Contributor
Hi, T.
That error appears to be correct, as auditing is not supported on resource or public folder mailboxes:
Cheers,
Lain