Working with Mailbox Rules in Powershell

Working with Mailbox Rules in Powershell
1. Get all forwarding rules in an organization:
foreach ($i in (Get-Mailbox -ResultSize unlimited)) { Get-InboxRule -Mailbox $i.DistinguishedName | where {$_.ForwardTo} | fl MailboxOwnerID,Name,ForwardTo >> C:AllForwardRules.txt }
2. To get inbox rules for a mailbox:
Get-Inboxrule. You can also do get-inboxrule | Fl to see details of the rule
3. Type Get-command *inboxrule* to see list of commands for inbox rules
4. To remove a rule, type get-inboxrule | remove-inboxrule
5. Create inbox rule called Junk for a set of users in a particular OU called Test. this will rule will move messages with subject ‘spam” to a folder called
Junk email
$mailboxes = Get-mailbox -organizationalUnit test
$mailboxes | % { }
$mailboxes | % { New-inboxrule -Name Junk -mailbox $_.alias -subjectcontainswords “[spam]” -movetofolder “$($_.alias):Junk Email” }

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: