2. Managing Transport Rules
You can use either the Exchange Management Console (EMC) or the EMS to create,
modify, view, enable, disable, remove, export, or import a transport rule on
both Hub Transport and Edge Transport servers.
2.1. Creating a Transport Rule
You can create transport rules on Hub
Transport or Edge Transport servers. Both server roles have many common
predicates and actions, but some predicates and actions are exclusive to
each Transport server role. Earlier in this lesson, you saw examples of the
use of EMS commands based on the New-TransportRule
cmdlet to create transport rules. You can also use the EMC to create a
transport rule. The high-level procedure to do this on a Hub Transport
server is as follows:
In the EMC Console pane, expand Organization Configuration and
click Hub Transport.
Click the Transport Rules tab on the Result pane.
Click New Transport Rule on the Actions pane. This starts the New
Transport Rule Wizard.
Complete the following fields on the Introduction page of the
wizard:
Name
Provide a name for the transport rule.
Comment
Optionally, use this field to describe what the rule
does.
Enable
Rule
New rules are enabled by default. If you want to
create the rule in a disabled state, clear this check
box.
If you want the rule to be applied to all email messages, do not
select any conditions on the Conditions page. Otherwise, complete
the following fields:
In the Step 1. Select Condition(s) box, select all the
conditions that you want to apply to the rule.
If you have selected conditions in the Select Conditions
box, click each blue underlined word in turn in the Step 2.
Edit The Rule Description By Clicking An Underlined Value
box. When you click a blue underlined word, a new window
opens to prompt you for the values to apply to the
condition. Select the values that you want to apply or type
the values manually and click Add. Repeat this process until
you have entered all the values and then click OK.
On the Actions page, shown in Figure 4, select all
the actions that you want to apply to this rule in the Step 1.
Select The Actions box.
Click each blue underlined word in turn in the Step 2. Edit The
Rule Description By Clicking An Underlined Value box. Specify
actions in the same way that you specified conditions in the
previous step.
If you do not want to define any exceptions, do not make any
selections on the Exceptions page. Otherwise, complete the following
fields:
Select all the exceptions that you want to apply to the
rule in the Step 1. Select The Exceptions If Necessary
box.
If you select exceptions, click each blue underlined word
in turn in the Step 2. Edit The Rule Description By Clicking
An Underlined Value box. Specify exceptions in the same way
that you specified conditions and actions in previous
steps.
Review the Configuration
Summary on the Create Rule page. If you are satisfied with the
configuration of the rule, click New.
A status of Completed on the Completion page indicates that the
wizard completed the task successfully. In this case, click Finish
to close the wizard. Otherwise, review the summary for an
explanation of the failure and click Back to make any required
configuration changes.
2.2. Modifying a Transport Rule
You can use the EMS or the EMC to modify an existing transport rule. To
use the EMC, you access the Transport Rules tab, as previously described in
the procedure, to create a transport rule. You then select the transport
rule you want to modify and click Edit Rule in the Actions pane. The
Introduction, Conditions, Actions, and Exceptions pages of the Edit
Transport Rule Wizard are the same as those in the New Transport Rule
Wizard, and you can edit the settings on these pages. You can review the
changes displayed in the Configuration Summary on the Update Rule page and
click Update if you are satisfied with them. Otherwise, click Back to make a
revision. Finally, click Finish on the Completion page.
You can use an EMS command based on the
Set-TransportRule cmdlet to modify a transport
rule. The following command modifies the transport rule TransportRuleExample
so that messages sent to Mark Harrington are sent to both Kim Akers and Don
Hall, unless they come from DonalMace@Contoso.com:
Set-TransportRule -Identity TransportRuleExample -AddToRecipients "Kim Akers","Don Hall"
-ExceptIfFrom DonalMace@Contoso.com
2.3. Viewing Transport Rules
You may want to list all the transport rules stored in Active Directory in
an Exchange Server 2010 organization or in AD LDS on an Edge Transport
server. You may also want to view the properties of a specific transport
rule. You can see a list of transport rules that apply to a Hub Transport
server (and to all other Hub Transport servers in the Exchange organization)
by expanding Organization Configuration and clicking Hub Transport on the
EMC pane. You then click the Transport Rules tab in the Result pane, and a
list of the transport rules appears on that tab. On an Edge Transport
server, the procedure is similar except that you click Edge Transport on the
Console pane, and the list on the Transport Rules tab applies only to the
current server.
If you want to view the properties of a transport rule, you can click on
the rule on the Transport Rules tab and then click Edit Rule on the Actions
pane. You can step through the pages of the Edit Transport Rule Wizard
without making any changes and hence view the transport rule
configuration.
You can use the EMS to view a summary list of all transport rules
configured on all Hub Transport servers or an Edge Transport server by
entering the following command:
Get-TransportRule
Figure 5 shows the output of this command
on Hub Transport server VAN-EX1. You might have a different list on the same
server on your test network. The list of transport rules on a Hub Transport
server in a production network is likely to be considerably longer.
You can obtain a list of the
properties of a specific transport rule by entering an EMS command similar
to the following:
Get-TransportRule TransportRuleExample | FL
Figure 6 shows some of
the output of this command.
Note:
You use the New-TransportRule EMS cmdlet to
create a new transport rule. You use the
Set-TransportRule EMS cmdlet to modify a
transport rule. This includes adding conditions, exceptions, or actions
to the rule. You use the Get-TransportRule EMS
cmdlet to display the properties of an existing rule. The
Get-TransportRuleAction EMS cmdlet allows you
to view the actions that the transport rule performs.
2.4. Enabling or Disabling and Removing a Transport Rule
The transport rule agent must be enabled before you can apply transport
rules to email messages that pass through a Hub Transport server, and the
edge rule agent must be enabled before you can apply transport rules to
messages that pass through an Edge Transport server. These agents are
enabled by default, but if an agent becomes disabled, all transport rules
are disabled. This is an unusual event possibly caused by a software fault,
but if you need to, you can use the following EMS command on either a Hub
Transport or an Edge Transport server to check the status of the appropriate
transport agent:
Get-TransportAgent
Figure 7 shows the output of
this command.
More typically, you may want to temporarily stop the execution of a single
transport rule. To use the EMC to disable a transport rule, you list the
transport rules on the Transport Rules tab, as described in the previous
section, Section 2.3; right-click the
transport rule you want to disable; and then click Disable Rule. You need to
click Yes to confirm this action. If a rule is already disabled and you want
to enable it, you right-click it and click Enable Rule. Note that disabling
a rule on a Hub Transport server disables that rule for all Hub Transport
servers in the Exchange organization. Disabling a rule on an Edge Transport
server disables that rule only on that particular server.
If a transport rule is no longer required, the procedure to remove it is
the same as the procedure to disable it, except that you click Remove
instead of Disable Rule. As with disabling a rule, you need to click Yes to
confirm the action. Take care that although you can enable a disabled rule,
you cannot retrieve a rule that you remove, and you need to re-create it (or
restore from backup) if you removed it in error.
You can use the EMS to disable and enable and to remove a transport rule.
For example, the following EMS command disables the transport rule
TransportRuleExample:
Disable-TransportRule TransportRuleExample
Note that this command requires confirmation unless you set the Confirm
switch to suppress this requirement. The following command enables the
transport rule that was previously disabled:
Enable-TransportRule TransportRuleExample
You can use a command based on the
Remove-TransportRule EMS cmdlet to remove a
transport rule. However, because this action is irreversible, it is a good
idea to use the WhatIf switch to determine the results of removing a rule
before you do so. You would enter a command similar to the following:
Remove-TransportRule TransportRuleExample -WhatIf
If you are sure it is what you want to do, you could then use a command
similar to the following to remove the transport rule:
Remove-TransportRule TransportRuleExample
You need to confirm this command unless you have configured the Confirm
switch so that confirmation is not required.
2.5. Exporting and Importing Transport Rules
If you want to duplicate the same transport rule on more than one Edge
Transport server, you can export it from the server on which you created it
and import it to other Edge Transport servers. Note that if you want to
replicate the entire Exchange configuration on all Edge Transport servers,
you should instead clone the Edge Transport servers.
Another situation in which you might want to export and import transport
rules is if you are configuring coexistence while updating an Exchange
Server 2007 organization to Exchange Server 2010. Exchange Server 2007
stores transport rules in a container that is different than that used by
Exchange Server 2010. Any existing transport rules that exist in the
Exchange 2007 container need to be converted and stored in the Exchange 2010
container so that the Exchange organization has the same set of transport
rules for both Exchange Server versions and the same messaging policies
apply. You export Exchange Server 2007 rules so that you can import them
into Exchange Server 2010 by entering an EMS command based on the
Export-TransportRuleCollection cmdlet and the
ExportLegacyRules parameter. This command runs on an Exchange Server 2010
Hub Transport server.
Note:
You can export Exchange Server 2007 transport rules and then import
them into Exchange Server 2010. However, you cannot export Exchange
Server 2010 transport rules and import them into Exchange Server
2007.
You can use the EMS but not the EMC to export and import transport rules.
The following two EMS commands export transport rules on an Exchange Server
2010 server running the Hub Transport or Edge Transport server role by
exporting transport rule data to the variable $transportfile and then
writing it to the Exchange2010TransportRules.xml file in the C:\MyDocs
folder:
$transportfile = Export-TransportRuleCollection
Set-Content -Path "C:\MyDocs\Exchange2010TransportRules.xml" -Value $transportfile
.FileData -Encoding Byte
The following two EMS commands, entered on an Exchange Server 2010 Hub
Transport server, export legacy transport rules created in Exchange
2007:
$transportfile = Export-TransportRuleCollection -ExportLegacyRules
Set-Content -Path "C:\MyDocs\LegacyRules.xml" -Value $transportfile.FileData -Encoding
Byte
Note:
TAKE CARE WHEN IMPORTING TRANSPORT RULES
Importing a transport rule collection from an XML file removes or
overwrites preexisting transport rules defined for the transport rules
agent. Ensure that you have a backup of your current transport rule
collection before you import and overwrite transport rules.
You export transport rules to an XML file and define the path of that file
in the EMS command. You can then import transport rules from that file. The
following EMS commands import transport rules from the ExportedRules.xml
file:
[Byte[]]$transportdata = Get-Content -Path "C:\MyDocs\ExportedRules.xml" -Encoding Byte
-ReadCount 0
Import-TransportRuleCollection -FileData $transportdata