Clone distribution group attributes

I was asked to create a distribution group, and then add all of the moderation settings, and message accept settings for the group.   I wanted to find an easy way to do this without having to use the GUI and add every single member, moderator, etc.

To do this, you create the distribution list the same way you would create one if you did not want to copy the values.  Once that distribution list has been created, you can do a few tricks to copy the values from the old DL to the new DL.

To start, you need to load the old DL into a powershell variable.  You can do this by typing in the following command.

$olddl = get-distributiongroup olddl

This assigns the attributes for the distribution group olddl to the variable $olddl.  You can just type $olddl in the powershell window and it will return the same results as the get-distributiongroup command would.

Now comes the trick.  Lets say there are a couple of attributes you want to copy from the olddl to the newdl.  For this example, lets say I want to copy ModeratedBy, BypassModerationFromSendersOrMembers, and AcceptMessagesOnlyFromSendersOrMembers.   You can type in the following command to do that.

set-distributiongroup newdl -ModeratedBy $olddl.ModeratedBy -ByPassModerationFromSendersOrMembers $olddl.ByPassModerationFromSendersOrMembers -AcceptmessagesOnlyFromSendersOrMembers $olddl.AcceptMessagesOnlyFromSendersOrMembers

If you then get-distributiongroup newdl | fl, you will notice that the newdl now has the same values, in those three attributes, as the olddl.

You can do this with almost any of the attributes in the olddl.  This makes it really easy to clone a distribution list.