Search
Windows Server

Microsoft Exchange Server 2010 : Setting Up Transport Rules (part 5) - Creating New Rules with the Exchange Management Shell

Published 1 min readBy Programming4us Editorial Team

5. Creating New Rules with the Exchange Management Shell

The following Exchange Management Shell commands let you add, change, remove, enable, or disable transport rules that are used by the Transport Rules agent on a Hub Transport server or an Edge Transport server:


Get-TransportRule

This cmdlet shows you the existing transport rules in your organization (if run on an HT server) or Edge server (if run on an ET server):

Get-TransportRule


Enable-TransportRule

This cmdlet sets an existing transport rule as enabled, which means it will be applied to messages:

Enable-TransportRule -Identity MyTransportRule


Disable-TransportRule

This cmdlet sets an existing transport rule as disabled, which means that it will still be present in the configuration but will not be applied to messages:

Disable-TransportRule -Identity MyTransportRule

The Disable-TransportRule cmdlet is useful for troubleshooting problems with transport rules. You can also disable all transport rules with this command:

Get-TransportRule | Disable-TransportRule


Remove-TransportRule

This cmdlet allows you to delete an existing transport rule:

Remove-TransportRule -Identity TransportRuleToDelete


Set-TransportRule

This cmdlet allows you to modify the parameters of an existing transport rule:

$Condition = Get-TransportRulePredicate FromMemberOf 
$Condition.Addresses = @((Get-DistributionGroup "Sales Group"))
Set-TransportRule -Identity FromSales -Condition @($condition)

To make this cmdlet manageable, we made use of variables to create the condition from a member of the distribution list and fill its Addresses property with the Sales Group distribution list. We then passed the variable into the Set-TransportRule cmdlet, modifying the condition of the FromSales rule.


New-TransportRule

This cmdlet allows you to create a new transport rule. From the EMS, issue the following command for a full description of the cmdlet, including examples:

Help New-TransportRule -full

You may have noticed in the previous examples of creating or editing a transport rule that when you reference the actions or the conditions, you have to use the object names. You can retrieve a list of the actions by using the Get-TransportRuleAction cmdlet and a list of the conditions using the Get-TransportRulePredicate cmdlet.