Managing Distribution Groups

Adding Members

Members can be added to a mail-enabled, universal group using powershell commands.

Extract details of the members from an existing group using the Get-DistributionGroupMember command. You can limit the information obtained to a single field e.g. PrimarySmtpAddress. The following command will do just that –

Get-DistributionGroupMember cmc-team |select PrimarySmtpAddress |Export-Csv cmc-addr.csv

The file it produces will be of the form –

#TYPE Selected.Microsoft.Exchange.Data.Directory.Management.ReducedRecipient


You need to produce a CSV file in the same format to add a list of members to a group. Import the CSV file to the group as follows –

Import-Csv cmc-addr.csv | foreach {add-distributiongroupmember -Identity cmc-team -member $_.PrimarySmtpAddress}

Note: If you have a list of staff IDs instead of addresses you need to use the SamAccountname attribute instead. The CSV file needs to be in the following format –

#TYPE Selected.Microsoft.Exchange.Data.Directory.Management.ReducedRecipient

The import command in this case would be –

Import-Csv cmc-sam.csv | foreach {add-distributiongroupmember -Identity cmc-team -member $_.SamAccountName}

Hiding List Membership

Sometimes you do not want recipients of messages sent via mail-enabled groups to be able to expand the recipient list. Do the following to hide the recipients –

  1. Open Active Directory Users and Computers console.
  2. Click View Menu and select Advanced Features (to enable it)
  3. Find your Distribution List or Security Group (mail enabled) in the OU. DO NOT search for your group because if you open the DL/Group properties from search windows, it will NOT show the Attribute Editor which is the advanced feature).
  4. Double click to open the DL/Group to see the properties. Go to Attribute Editor tab.
  5. Find hideDLMembership attribute, double click to open and select True. Click OK twice to close the dialog boxes.

It takes a while to take effect the changes while Exchange generates Offline Address Book and Outlook installations retrieve it.

Copy Contents From One Office 365 Mailbox to Another

Open powershell and connect to Exchange Online (see earlier post).

You can only copy the contents from the source mailbox into a folder on target mailbox. Use the following command –

Search-Mailbox source-id -TargetMailbox target-id -LogLevel full

You will be prompted to enter a folder name. Once you have entered the name the command will run. This will probably take several minutes and a small report will be displayed at the end.

Close the session to Exchange Online

Connect to Exchange Online

On your local computer, open Windows PowerShell and run the following command –

$UserCredential = Get-Credential

In the Windows PowerShell Credential Request dialog box, type your Office 365 user name and password, and then click OK.

Run the following command –

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $UserCredential -Authentication Basic -AllowRedirection

Then run the command –

Import-PSSession $Session

You need to connect to the Microsoft Online Service for a number of operations. To do so run the following command using the credentials you input as above –

Connect-MsolService -Credential $UserCredential

Once you have finished with the session run the command –

Remove-PSSession $Session

OWA – Silent Redirection to Office365

If a user’s mailbox is in Office 365, the CAS server issues a redirect to Office 365 when the user has successfully authenticated. By default, it pops up a nuisance, interstitial page that requires an extra click (and can turn into a black hole),
This is avoided by adding the following code to C:/Program Files/Microsoft/Exchange Server/V14/ClientAccess/Owa/casredirect.aspx immediately above the line <!DOCTYPE HTML…

if (RedirectionUrl.Contains(“”)) {

You need to do this every time there is an update to the Exchange software.

Checking and De-listing Mailhubs Blacklisted by Hotmail/Live

Login at with a valid hotmail/live account. I have set up the account for this. Make sure you know the password (ask Clive McDowell).

Once you have logged in open another browser tab and go to The useful links are –

  1. View Data: summary report on host IP addresses with historical data going back possibly months.

  2. View IP Status: gives a list of any IPs that are blacklisted.

  3. Request Access: allows you to add IP addresses or address ranges to be included in the reporting.

The other links should be self-explanitory.

If one of the IPs is blacklisted go to this link and fill out the form. You will usually get an automated response fairly quickly but it’s really up to them how soon they take any action. In recent times it has only been a few hours.

Exchange 2010 Failed Database Content Indexes

Failed content indexes can easily go unnoticed when everything else is working fine however they will eventually begin to cause problems for you, for example by preventing database switch overs. You can list all failed indexes with the following command –

[PS] C:\>Get-MailboxDatabaseCopyStatus * | where {$_.ContentIndexState -eq “Failed”}

If any databases are listed the indexes can be fixed by piping the output from the command above into the Update-MailboxDatabaseCopy cmdlet as below –

[PS] C:\>Get-MailboxDatabaseCopyStatus * | where {$_.ContentIndexState -eq “Failed”} | Update-MailboxDatabaseCopy -CatalogOnly

Once this has completed run the first command again. It should not return anything if successful.

Message Tracking

Use EMS commands to retrieve message tracking data across several hub transport and mailbox server hosts as follows –

Get-ExchangeServer | where {$_.isHubTransportServer -eq $true -or $_.isMailboxServer -eq $true} |`
Get-MessageTrackingLog -sender "" -Start "7/28/2012 8:00AM" -End "7/28/2012 5:00PM"


This is a split one-line command so watch out for the trailing back-tick!

Check help on the Get-MessageTrackingLog commandlet for other switch options e.g. trawl for recipients, message ID etc.

From Pegasus to elsewhere

A user recently had the desire to move away from the email client they’d been using for some time, and had requested assistance. In this case, they were using a version of Pegasus (Version 4.6, I think). Vaguely recalling that you can import  data from various email clients to Thunderbird, I looked for a tool to convert the folders in the /Mail/ directory for Pegasus to something Thunderbird would use. Having read a little about it, I knew I needed to find a way to convert the folders to .mbx files, and found one called Mail System Converter here. It was then possible to move the folders and retain the email in a new client, or move it to an account on a server.

First install Thunderbird, and then add an IMAP account using your credentials. Having made sure this is connecting correctly, close down Thunderbird.

Using Mail System Convertor, you can use the ‘Folders’ menu, then select ‘Export from Pegasus’ to create files usable by Eudora. Having done so, simply move these .mbx files to:

C:\users\<yourusername>\AppData\Roaming\Thunderbird\Profiles\<random>.default\Mail\Local Folders\

Open Thunderbird again, and you can now see these as local folders. If you so wish, you can now drag them to your email account on your server.

Exim on Centos

The version of Exim that comes with rpmforge is currently 4.63 which is somewhat lower than the latest version. Rpms for the latest version (currently 4.77) is available from atrpms. Create the file /etc/yum.repos.d/atrpms.repo on any target machine and add the following content –

name=Centos $releasever – $basearch – ATrpms
includepkgs=libspf2* libsrs*

name=Centos $releasever – $basearch – ATrpms

To update exim simply run yum update exim