How to create Mail enabled distributionlist importing excel or csv file using powershell

Posted on 2009-04-24
Medium Priority
Last Modified: 2013-12-17
Excel or csv file has E-mail id, Distribution members and all field.

Need to Hide from Exchange address list.
Question by:kavidevan
  • 3
  • 2
LVL 71

Expert Comment

by:Chris Dent
ID: 24231664

I would use a CSV file, so much less bother than Excel. Where is the distribution list name set?

Unless you're using Exchange 2007 I recommend grabbing these CmdLets:


With that, if the CSV looked like this:

Name            Email                Username
Chris Dent    me@here.com   cdent

That would perhaps allow something like this:

$GroupName = "Some Group"
Import-CSV | %{ Add-QADGroupMember $GroupName -Member $_.Username }
Get-QADGroup $GroupName | `
  Set-QADGroup -ObjectAttributes @{'msExchHideFromAddressLists'=$True}


Author Comment

ID: 24246820
Hi Chris,

I have attached the Excel sheet, I need to create as per excel sheets and users to get added to the concern DL's given.
Hence i am waiting for such powershell script to make the process simple..
At the same time, in the above mentioned script, I am not mentioning the CSV path. Please let me know the exact script for the attachment to create DL in AD.
LVL 71

Expert Comment

by:Chris Dent
ID: 24250165

That's quite a horrible spreadsheet ;)

I'll happily help you import from a CSV, but to be honest I find Excel in PowerShell to be a bit of a pain in the neck and won't touch it if I can possibly avoid it.


Author Comment

ID: 24262573
Ok Chris,

I will convert in to CSV file.. Please give me the powershell command and suitable column and its details for CSV file
like               Distribution name     Member E-mail Address        Hide from exchange   Manageby
                     kavi                           kavi      kavi@hotmail.com

to get imported to Exchange...
LVL 71

Accepted Solution

Chris Dent earned 2000 total points
ID: 24277565

Cool okay, that is easier :)

$Groups = Import-CSV "FileName"

So we're potentially going to take that and do this:

$Groups | %{
  $Group = Get-QADGroup $_."Distribution name"
  $User = Get-QADUser -Email $_."E-mail Address"
  $Group | Add-QADGroupMember -Member $($User.DN)

  If ($Groups."Hide from exchange") {
    Set-QADGroup $($Group.DN) -ObjectAttributes @{'msExchHideFromAddressLists'=$True}

Are we setting ManagedBy as well? If so, what value will be stored in that column? And will you be wanting it to tick the box allowing the manager to update (that's the most complex step here).


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
Among the most obnoxious of Exchange errors is error 1216 – Attached Database Mismatch error of the Jet Database Engine. When faced with this error, users may have to suffer from mailbox inaccessibility and in worst situations, permanent data loss.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question