Backup and Restore Distribution Groups from Exchange or Exchange Online

I've been involved in a lot of Exchange migrations over the years, to and from all sorts of different environments.

On a current engagement, I had to export a ton of cloud-managed distribution lists and their members from Office 365 / Exchange Online Dedicated and import them into Office 365 Multitenant.  I wrote a script to help accomplish this.

For anyone faced with this challenge (or, from the documentation perspective in the event of a disaster or a demanding boss--though there may be no distinction between those two), here's something to put in your bag of tricks.

I took a tool that I had written several years ago and figured it would just work with Office 365 Dedicated.  O365D environments are typically large, with hundreds of thousands of objects.  In this particular case, my O365D tenant contained nearly 60 domains, so I only wanted to extract distribution groups where the primary SMTP address suffix matched a particular subdomain.  I debated with ways to do this (server or client side filtering), and because I was lazy, I used the client side filtering.  Fortunately, most environments (even for very large customers) don't usually have more than a few thousand groups, so client-side filtering isn't too terrible.  In a future post, I'll show you how I solved the problem with Server Side filtering for the same customer.

The script that I put together will allow you to both export and import distribution lists and their members, giving you a log of objects that it fails to add (for example, if the object to be imported doesn't exist).  This might happen if you're trying to move from one environment to another.

You can check out the entire script at the TN gallery.