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


EXCHANGE COMMAND


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



ACTIVE DIRECTORY COMMAND

 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:

       SamAccountName
       bsm
       chh
       des

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.

Error 1312 when adding ssl cert

 If you get an error when using netsh to add a cert thumbprint, make sure you have a private key attached to the cert. Also, make sure the c...