-->

Sunday, May 13, 2018

Exchange - Compare Distribution Group Members to Dynamic Distribution Group Members

I recently "converted" several Distribution Groups to Dynamic Distribution Groups in my Exchange environment. I say "converted" because there's no direct way to do so; you have to build new DDLs, delete the old DLs and move the DisplayNames, SMTP addresses and LegacyDN's over to the new ones.
 
The issue I had was, we use Attribute15 as our location code, which is where the DDLs pull the membership info from (see this post if you're interested how I created them) and I wanted to make sure that the users who were in the old DLs are also members of the new DDLs. And if they aren't listed in the new ones, most likely the Attribute15 is missing, so we can fix that easily.
 
There's no way in the EAC to see the members of Dynamic Groups; that has be done in the Shell, so I created a script that will compare Distros to Dynamic Distros, and spit out a CSV report for you.
 
You can grab the script from my Google Drive here
 
--or--
 
Copy and past the following block into Notepad, and save as Compare-DL-With-DDL.ps1
 
$name = Read-Host "Enter a Distribution Group Name"
$DL = Get-DistributionGroupMember –Identity "$name"
$dynname = Read-Host "Enter a Dynamic Distribution Group Name"
$members = Get-DynamicDistributionGroup -Identity "$dynname"
$DDL = Get-Recipient -ResultSize 1000 -RecipientPreviewFilter $members.RecipientFilter
Compare-Object $DL $DDL -IncludeEqual -Property DisplayName | export-csv DLLCompare.csv -notypeinformation
 
Once you have the script saved, fire up the Exchange Management Shell and cd to the location where you saved it.
 
Next, run Compare-DL-With-DDL.ps1

The script will prompt you to input the name of a regular Distribution Group

It will then prompt to enter the name of Dynamic Distribution Group

When it finishes, it will create a CSV report in the location where you ran the .ps1 from.

In the report, you'll get the Display Names for the users, and the "SideIndicator" which tells you whether the users exist in both groups, or one or the other.

The side indicators will look like so:

==” indicates that the user is present in both groups
=>;” indicates that the user is present only in the second group, this will be the New DDL
<=” indicates that the user is present only in the first group, the Old DL

And example report would be:

DisplayName               SideIndicator
User1                            ==
User2                            ==
User3                            <=
User4                            <=
User5                            =>
User6                            =>

So, according to the list, we'll need to fix User3 and User4, as they aren't included in the New Dynamic List; something is missing from whatever we filtered on to create the DDL (in my case Attribute15 is empty)

For User5/6 we don't need to worry about them, they probably just weren't manually added to the old list, and from now on they'll get those "all important" pizza lunch emails :)

Now, you have your comparo list, you can hand it off to your AD team to fix attributes, or if you're "lucky" and you do it all yourself, go fix it!

**Note** If you need to hand the report off to non-tech people, you can use Excel  to do Find/Replace to the change the Side Indicators to something readable like "== is Both", "=> is New DDL", "<= is Old DL"

No comments:

Post a Comment