Tag Archives: Script

Mail Enable All Existing Distribution Groups within an OU

Using the EMC to mail enable a distribution group is incredibly inefficient as you can only perform the action on one group at a time.  The EMS isn’t much better as there is not a native command to target every group within a specific OU.

Why would you need to mail enable a distribution group?  Well, remember with Exchange 2007/2010, you could create a new group in Active Directory Users & Computers, and even make it a Universal Distribution Group, but Exchange won’t see it until you mail enable it.  In my case, I had to import a LARGE number of groups from a recent aquisition, so I had them in AD but did not have them mail enabled yet.

In order to do this, we need to create a new PowerShell script with the following code:

Get-Group -OrganizationalUnit "OU=users,DC=domain,DC=com" | ?{ $_.GroupType  -Match "Universal" } | %{ 

# Check to see if the group is mail enabled or not.   

   If ($_.RecipientType -eq "Group") {
      Enable-DistributionGroup $_.DistinguishedName
   }
}

Just change the “OU=users,DC=domain,DC=com” to whichever OU you are targeting and you should be good to go.

How to Add Your Exchange 2010 Server as a Replica for all Public Folders

If you’re in a position where you must continue to use Public Folders with Exchange 2010, and you need to add your new Exchange 2010 server as a replica on a plethora of Public Folders, it’s surprisingly easy to add it to the list of replicas for every Public Folder.

You probably already know that simply adding it as a replica to the parent folder doesn’t quite do it.  However, Microsoft has a script built for Exchange 2010 that will do all of the hard work for you.

Simply open the Exchange Management Shell and navigate to the \scripts folder in your Exchange installation directory.  Once there, do the following:

  1. Run .\AddReplicaToPFRecursive.ps1
  2. Type in “\” when it prompts for the TopPublicFolder
  3. When it prompts for Server To Add, just type in the name of your Exchange 2010 server that is hosting the public folder database.

That’s it, the script may take a while to run (it won’t give any indication that it is doing anything), but it will ultimately complete.  When it does, you should see your 2010 server as a replication partner on every single public folder, which you can validate by running this command:


Get-PublicFolder –Recurse | fl Name, Replicas

Note that it might take a few minutes for the added servers to show up if you have a large number of replicas.

More details from Microsoft are available here:

http://technet.microsoft.com/en-us/library/aa997966.aspx

How to add Proxy SMTP Address from Exchange Management Shell

Microsoft’s article related to adding an email address to an existing mailbox in 2010 is here:

http://technet.microsoft.com/en-us/library/bb123794.aspx

However, I really didn’t like how they do it as it relies on multiple line entries to add a single address.  So I sought out the command below to be able to add an address with a single line.


Set-Mailbox [user alias] -EmailAddresses (((Get-Mailbox [user alias]).EmailAddresses)+="smtp:proxy_address@domain.com")

Better yet, by using Excel and some nifty concatenate work, you can make yourself a nice spreadsheet to apply multiple changes at once.  If you didn’t already know, you can copy and paste in multiple commands at once, and the Exchange 2010 Powershell will process each line as an independent command.

…scripting for dummies I guess : )