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

Posted on 2009-04-24
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
    LVL 70

    Expert Comment

    by:Chris Dent

    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   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

    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 70

    Expert Comment

    by:Chris Dent

    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

    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

    to get imported to Exchange...
    LVL 70

    Accepted Solution


    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).


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    When it comes to providing great business solutions, IBM and Microsoft are the two top companies excelling in the art. Both launch similar products aimed at a wide audience set and have a good customer satisfaction rate. Since their products are qui…
    Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
    The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
    This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now