Given a list of users, get distribution groups they manage !

Hi, I got a request to generate a powershell script.  So, say you have a list of users that you need to know which mailing group they manage, and output the results in an CSV file.

This script will take two input variables :

  • InputFile : required parameter, which is the text file containing all usernames that you want to see which mailing groups they manage. Example: c:\users.txt
  • Outfile : required parameter, which is the csv file to generate. Example is c:\output.csv

So, say you have a text file named c:\users.txt that contains three lines ( Johns, JeorgeM, AliceO), then you can type the following :

Get-SpecificDGManagers -inputfile c:\users.txt -outfile c:\output.csv 

So the output.csv will contain a list of those three users along with all mailing groups they manage.

Download the script

You can download the script from here:  Get-SpecificDGManagers

Note: the list of users in c:\users.txt should be the samaccountnames and not the displaynames of the users 🙂 this is to ensure uniqueness.

Note: If no output is available ( the users are not managing any groups, then no csv will get generated). Run the script in verbose mode to see more info 🙂

Note: run it from Exchange Management PowerShell with user that has read access only.

2 comments on “Given a list of users, get distribution groups they manage !

  1. first of all thanks for preparing this script

    I have question here, if i execute the script from EMS Get-SpecificDGManagers.ps1. will it create a new cmdlets in exchange server. Please explain it.

    • Hi,
      Thanks for your question.
      I do not think i understand your question, but let me try my best to explain.

      Follow these steps to run the script:
      – Copy the script to that Exchange Server and place it on the C drive.
      – Go to your Exchange Server and Run the Exchange PowerShell Management Console and run the following command: C:\Get-SpecificDGManagers.ps1 -InputFile C:\users.txt -OutFile C:\Output.csv

      Assuming you already have a text file on the C:\ drive called users.txt.

      Saying that, Exchange PowerShell Console will go to the C drive, search for a script called Get-SpecificDGManagers.ps1 on the C drive, and will start executing the commands inside it.

      Pls advise if you need further help

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s