locked
Enable-DistributionGroup and Export-CSV RRS feed

  • Question

  • Hi all. I have distribution groups (more than 100) that I have to turn into mail-enable dist groups. I can use powershell command (Enable-DistributionGroup -Identity "groupname" -DisplayName "name" -PrimarySmtpAddress "address") to set just one group at once, but it takes a lot of time. How I can use import-csv for this action? 
    Friday, July 27, 2018 12:51 PM

Answers

  • You can't use export-csv for that but import-csv.

    $CSV = Import-CSV -Path "your_csv" -Delimiter "your_delimited"

    $CSV | ForEach-Object {

    Enable-DistributionGroup -Identity $_.GroupName -DisplayName $_.DisplayName -PrimarySmtpAddress $_.PrimarySmtpAddress

    }

    Now let's create a CSV with 3 headers : GroupName ; DisplayName ; PrimarySmtpAddress

    Choose which delimiter you want (; or , or tab or space, or anything else) modify the -Delimiter parameter and here we go

    ++

    Friday, July 27, 2018 12:57 PM

All replies

  • Use a loop. 

    Start by learning how to use PowerShell beyond a single command.


    \_(ツ)_/

    Friday, July 27, 2018 12:56 PM
  • You can't use export-csv for that but import-csv.

    $CSV = Import-CSV -Path "your_csv" -Delimiter "your_delimited"

    $CSV | ForEach-Object {

    Enable-DistributionGroup -Identity $_.GroupName -DisplayName $_.DisplayName -PrimarySmtpAddress $_.PrimarySmtpAddress

    }

    Now let's create a CSV with 3 headers : GroupName ; DisplayName ; PrimarySmtpAddress

    Choose which delimiter you want (; or , or tab or space, or anything else) modify the -Delimiter parameter and here we go

    ++

    Friday, July 27, 2018 12:57 PM
  • Oh yes, I mean import-csv. Thanks, I'll try! 
    Friday, July 27, 2018 1:11 PM