antonioking
asked on
Powershell inbox rule script - ExceptIfSentTo not adding multiple addreses
I have a PowerShell script that I want to run every day (on schedule) that will add a rule to all new user mailboxes.
The rule is needed to move emails sent from our CRM into the users sent items folder.
The script completes successfully however upon checking the created only the first address of the exceptifsentto property is added.
How do I add multiple addresses to the Except if Sent to exception on the rule?
Kind regards
Antonio
Thanks
The rule is needed to move emails sent from our CRM into the users sent items folder.
add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
$yesterday = (get-date).AddDays(-1)
Get-Mailbox -ResultSize unlimited |
? { $_.whenCreated -ge $yesterday } |
% {
Add-MailboxPermission -identity $_.identity -user administrator -AccessRights FullAccess
New-InboxRule -Mailbox $_.identity -Name "Move BCc msgs to myself to Sent Items" -From $_.PrimarySmtpAddress.tostring() -ExceptIfMyNameInToOrCcBox $true -ExceptIfSentTo "sales@domain.com,everyone@domain.com" -MoveToFolder "$($_.alias):\Sent Items"
}
The script completes successfully however upon checking the created only the first address of the exceptifsentto property is added.
How do I add multiple addresses to the Except if Sent to exception on the rule?
Kind regards
Antonio
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER