Hi,
I've been asked to look at turning mailbox auditing on on our Exchange Server. Looking around there is plenty of information on Powershell commands to do it. However, I want to look at limiting it to mailboxes within a particular mail database at this point and so I have applied the -WhatIf command to see what the result would be before applying but I get an error. I dont use Powershell a great deal as yet so am unsure as to what I might be doing wrong here:
Command that I was trying to run:
$UserMailboxes = Get-Mailbox -Database 'Database 01' -Filter {(RecipientTypeDetails -eq 'U
serMailbox')} $UserMailboxes | ForEach {Set-Mailbox $_.Identity -AuditEnabled $true} -WhatIf
Error:
ForEach-Object : Cannot bind parameter 'Process'. Cannot convert the "-WhatIf" value of type "System.String" to type "S
ystem.Management.Automation.ScriptBlock".
At line:1 char:126
+ $UserMailboxes = Get-Mailbox -Database 'Staff 06' -Filter {(RecipientTypeDetails -eq 'UserMailbox')} $UserMailboxes |
ForEach <<<< {Set-Mailbox $_.Identity -AuditEnabled $true} -WhatIf
+ CategoryInfo : InvalidArgument: (:) [ForEach-Object], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.ForEachObjectCommand
Am I missing something in the original command or should be structuring this differently?
Thanks.