Exchange Server 2007 Email Routing, Part 3 – Using the Exchange Management Shell

If you would like to read the previous articles in this series please go to:

Part 1 and Part 2 of this article discussed the design of Exchange Server 2007 Email Routing and how to configure it using the Graphical User Interface. Exchange Server 2007 also allows another management possibility – the Exchange Management Shell. Within this article we will have a look at how to configure Email routing in Exchange Server 2007 using the Powershell console.

Configuring Transport Server Properties

Transport Server is the server role that is responsible for message routing.

To view Transport Server configuration, you just have to use the Exchange Management Shell Command “get-transportserver”, to set any new configuration “set-transportserver” is your goal:

Figure 1: Viewing and Setting Transport Server Configuration

If a send connector is trying to send emails using external DNS lookup settings, it uses the external DNS setting configured on the transport server. This external DNS setting also applies to receive connectors for anti-spam agents like Sender ID or connection filter agents.

To configure this using the command prompt, enter the following:

Figure 2: Configuring External DNS Server Settings

To configure internal settings just replace the “external” string in the expressions above with “internal” and it works.

In general the cmdlet Set-TransportServer supports the following settings:

  • Outbound Connection failure retry interval in minutes
  • Transient failure retry interval in seconds
  • Transient failure retry attempts
  • Message expiration
  • Notifications
  • Connection Restrictions (maximum concurrent outbound connections & maximum concurrent outbound connections per domain)

Managing Accepted Domains

Accepted Domains are global settings for the Exchange organization and on Edge Servers. These settings define whether Exchange is responsible for an SMTP domain or not. It is recommended that you configure all accepted domains in these global settings and synchronize them to your Exchange Server holding the Edge Server Transport Role in the DMZ.

We sort the accepted domains into groups:

  • Authoritative Domains
  • Relay Domains:

    • Internal –> recipients in this domain do not have mailboxes in this Exchange organization but have contacts in the global address list (GAL)
    • External –> messages are relayed to an email server outside your Exchange organization by your Edge Transport server.

To create an accepted domain you will have to use the following commands:

Figure 3: Configuring Accepted Domains

To change an accepted domain type, you should use the following syntax:

Figure 4: Changing the accepted domain type

To remove an accepted domain you can use the following command:

Figure 5: Remove Accepted Domains

You should make sure that it is not your default, because this cannot be removed anyway.

In addition to this you can configure email policies with the command shell, too.

Figure 6: Set Email Address Policy

This command changes the primary email address assigned to receipients and keeps the existing email address as secondary.

Managing Connectors

A connector defines a logical connection between source and destination server. They describe how servers communicate. The default communication protocol is SMTP, all receive connectors accept only SMTP, but send connectors (e.g. to foreign email systems) accept SMTP, X.400, etc.

A receive connector defines:

  • Number of active connections
  • Maximum message size
  • Maximum recipients per message
  • And more…

To create a new send connector you will have to use the following command:

Figure 7: Creating new send connectors

In addition to this you can create a linked connector, which is a receive connector that is linked to a send connector. For linked connectors the general routing logic based on destination domain is overridden. In general, a linked connector can be used when sending messages to a 3rd party anti-spam or antivirus service for processing and then return it to Exchange for proper delivery.

To configure how Exchange receives email, we will now have a look at the receive connector configuration.

Figure 8: Creating a custom receive connector

If you now want to remote a receive connector, that is quite easy when working with the Exchange Server Management Shell.

Figure 9: Removing an existing receive connector

When considering security settings on your connectors you will have to choose between anonymous and secure relaying. As we all know relaying means receiving and sending emails, if ever possible we should configure each Exchange Server to only allow relaying on, e.g. specific IP-Addresses. This means that your Exchange Server box is configured to send emails only to the relay server and receives only from this one.

Figure 10: Configure Anonymous Relay for specific IP-Addresses

As you can see we now have to use two commands. The first was for creating the receive connector with anonymous relay restrictions; the second one was to configure the appropriate security settings in Active Directory.

Managing Queues

After having had a look at the configuration of Exchange Server and its connectors for sending and receiving messages, we will now have a look at the queue management functionalities of the Exchange Server Management Shell.

If you would like to retrieve special messages within your queue, this command should help you:

Get-Message –Server Servername.domain.tld –resultsize 500 –sortorder +FromAddress,-size

In addition to this you can start every task known from the Exchange Management Console within your Exchange Management Shell, likewise:

  • Suspending Queues
  • Resuming Queues
  • Remove Queues
  • Remove specific messages from Queues
  • Export Messages from Queues
  • Resubmit Messages from Queues
  • And more…


As shown in my article above you can see that the new Microsoft Exchange Management Shell is a quite interesting but complex tool to fully and easily administer your Exchange Server 2007 environments. You just have to know what cmdlet you will have to use to finish off your work properly.

In addition to this, the Management Shell allows you to create PowerShell Scripts, save them, and run them every time you need them. This makes your general work quite easier than it was before.

If we compare the features and functionality of the Exchange Management Shell with the Exchange Management Console we will see that lots of commands are currently not available in the console and only in the shell. Information from the Microsoft Exchange Team Blog indicates that these missing features will be part of Service Pack 1 for Exchange Server 2007 which will be released soon.

If you would like to read the previous articles in this series please go to:

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top