Home > Exchange, Powershell > Enumerate Distribution Groups Script Updated…

Enumerate Distribution Groups Script Updated…

A reader sent in a question asking how to enumerate groups that have spaces in them and this lead me to realize I didn’t follow the specifications for valid distinguished names as well as I thought I had.  If you take a look at RFC 2253 and the Microsoft page that defines security group names, you will see what the allowed characters are for these names.  At this point the validation is a lot better, but it still isn’t perfect.

If you encounter a situation where you need to enumerate members of a group that my validation does not allow, you can scroll down to line 271 in the script and change the $rx variable to “.+” to make it simple which will allow you to pass any characters.  If you pass invalid characters you will get some funny errors happening, but it should work.  You may have to use quotes around the name if you are looking to use spaces or other allowed special characters.

Taking another look at the code, I also found a small bug that was causing the display of notes associated with a group to print out an error about null strings.  This should be fixed now.  If anyone notices any other problems, feel free to comment and let me know and I will try to fix it or add in the change as soon as possible.  I’ll be posting another update soon that goes the other direction of this script, one that enumerates group membership for a specific user.

Thanks again to Darren from Brisbane(?), Australia for pointing this out.

Here is the updated script download link: Download enumerate_groups.ps1Download enumerate_groups.ps1

Categories: Exchange, Powershell Tags: , , ,
  1. CHigbee
    January 5th, 2011 at 17:01 | #1

    I’m having a problem with “ResultSize” errors, and apparently missing the correct placement within the script.

  2. January 19th, 2011 at 11:02 | #2

    I would imagine you are having an issue with resultsize when getting members, not when it is doing the initial enumeration of groups… but correct me if I am wrong. Most likely you will need to add a resultsize parameter to the get-distributiongroup, get-dynamicdistributiongroup, or get-recipient calls. You may only need to modify one of those of course, depending on the details of your situation, but it shouldn’t hurt to add it to all of them.

    Check lines 170, 174, 208 and 209 to add -resultsize.

    Good luck!

  1. July 19th, 2009 at 21:35 | #1
You must be logged in to post a comment.