Tuesday, December 13, 2016

Add Members to Distribution Group From CSV File

I had a hard time finding a simple way to add users to an existing DL from a CSV file. I stitched together a couple ways I found on the web. One uses an Exchange powershell command and the other uses an active directory powershell command


Import-CSV "File Name.csv" | ForEach {Add-DistributionGroupMember -Identity "Group Name" -Member $_.SamAccountName}


 Import-Csv "File Name.csv" | % {Add-ADGroupMember -Identity "Group Name" -  Member $_.SamAccountName}

In both cases you must have a CSV file with a header of SamAccountName and then the user accounts below that. For Example:


Also, if you use the Active Directory Command inside an Exchange Management Shell, be sure to import the AD module:

import-module activedirectory

You can put in another header if you like (UPN, SMTP Address, etc), but I've found SamAccountName works best for me.

No comments:

Post a Comment

User unable to login to RDP Farm after you re-enable them?

We had a strange issue. We had a user leave and since we knew when she was leaving i set the account to expire at a certain date. A couple d...