So, I found a relatively straight forward article on how to automatically enable auditing on all new mailboxes created using the scripting agent here:
http://exchangeserverpro.com/automatically-enabled-mailbox-audit-logging-exchange-server/
I have my XML files in place on all Exchange servers, and I've enabled the scripting agent. Now when I attempt to create a new mailbox, it does create it but I get an error when it tries to enable the auditing. The error:
WARNING: The cmdlet extension agent with the index 5 has thrown an exception in OnComplete(). The exception is: Microsoft.Exchange.Provisioning.ProvisioningException: ScriptingAgent: Exception thrown while invoking scriptlet for OnComplete API: Cannot convert 'System.Object[]' to the type 'Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter' required by parameter 'Identity'. Specified method is not supported.. ---> System.Management.Automation.ParameterBindingException: Cannot convert 'System.Object[]' to the type 'Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter' required by parameter 'Identity'. Specified method is not supported. ---> System.NotSupportedException: Specified method is not supported.
I've played around with the script from the original configuration in the article as you can see here in my XML:
<?xml version="1.0" encoding="utf-8" ?> <Configuration version="1.0"> <Feature Name="MailboxProvisioning" Cmdlets="New-Mailbox,Enable-Mailbox"> <ApiCall Name="OnComplete"> if($provisioningHandler.UserSpecifiedParameters["Identity"] -ne $null) { $ID = $provisioningHandler.UserSpecifiedParameters["Identity"] Set-Mailbox -Identity $ID -AuditEnabled:$true } </ApiCall> </Feature> </Configuration>
But to no avail. I always get the same error. I am working with Exchange 2013 SP1.
Any thoughts?