Create DG from a CSV file
Hello,I need to create 30 Distribution Groups I already have in a CSV file (or notepad) under Exchange 2007.1 - I'm looking for script to create the 30 Distribution Groups from notepad/csv file 2 - I'm looking for script to add list of users (available in a notepad/cvs file) to a list of specific distribution group (those DGs are available in a notepad/cvs file)Thanks in advance,Graig
February 8th, 2010 2:58pm

To create distribution groups from a list (notepad file) named new_dls.txtgc new_dls.txt |%{new-distributiongroup -name $_ -type "Distribution" }You'll need to add parameters for alias, displayname, smtp addresses, etc if you want them to be other than defaults.If you want to set these per DL at creation time, you probly want to use a .csv that includes fields for those values per DL. If you want to use .csv instead, post back with an example of what your .csv looks like.Adding users to a DL named TestDL from a list named new-dlmembers.txt can be as easy as:gc new-dlmembers |%{add-distributiongroupmember "TestDL" -Member $_}Depending on your domain, you may need to specify the group name and user names as DNs (or some other unique ID parameter) if the common names result in ambiguous resolutions.
Free Windows Admin Tool Kit Click here and download it now
February 8th, 2010 4:30pm

Hello,Thank you for your reply :)My text file is called --> try.txtand the contain is: xx.IT-Z2.interview@company.comxx.IT-Z3.interview@company.comxx.IT-Z4.interview@company.comxx.IT-Z7.interview@company.comxx.IT-Z8.interview@company.comxx.IT-Z9.interview@company.comWhen I type: gc try.txt | %{new-distributiongroup -name $_ -type "Distribution"}I got the below error message :Get-Content : Cannot find path 'C:\try.txt because it does not exist.At line:1 char:3+ gc <<<< try.txt |%{new-distributiongroup -name $_ -type "Distribution"}Beside note: I need those distribution groups to be reached by external user.Below you have an existing DG detail: GroupType : UniversalSamAccountName : Sam.pleExpansionServer :ReportToManagerEnabled : FalseReportToOriginatorEnabled : TrueSendOofMessageToOriginatorEnabled : FalseManagedBy :AcceptMessagesOnlyFrom : {}AcceptMessagesOnlyFromDLMembers : {}Alias : Sam.pleGrantSendOnBehalfTo : {}HiddenFromAddressListsEnabled : FalsePoliciesExcluded : {}EmailAddressPolicyEnabled : TrueRecipientType : MailUniversalDistributionGroupRecipientTypeDetails : MailUniversalDistributionGroupRejectMessagesFrom : {}RejectMessagesFromDLMembers : {}RequireSenderAuthenticationEnabled : FalseSimpleDisplayName :UMDtmfMap : {}IsValid : TrueName : Sam.ple
February 8th, 2010 5:47pm

gc (get-content) assumes the file you're getting the content from is in the shell default path if all you give it is a file name. If it's not, you need to specify the full path:gc "c:\try.txt" | %{new-distributiongroup -name $_ -type "Distribution"}
Free Windows Admin Tool Kit Click here and download it now
February 8th, 2010 6:34pm

It is much better this way!!However, I am asked to enter the SamAccountName :cmdlet new-distributiongroup at command pipeline position 1Supply values for the following parameters:SamAccountName:Shall I create a csv file? or add something else in my text file?xx.IT-Z2.interview@company.comxx.IT-Z3.interview@company.comxx.IT-Z4.interview@company.comxx.IT-Z7.interview@company.comxx.IT-Z8.interview@company.comxx.IT-Z9.interview@company.com
February 8th, 2010 6:49pm

I'd create a .csv file.You can use whatever you want for the column headings, but I'd avoid using column names with embedded spaces - if you do that you end up having ot quote the property names in the script, and it's a PITA.
Free Windows Admin Tool Kit Click here and download it now
February 8th, 2010 6:56pm

To add users to DG you can use the script created by Microsoft in this link (http://liveatedu.spaces.live.com/blog/cns!C76EAE4D4A509FBD!215.entry or http://liveatedu.spaces.live.com/blog/cns!C76EAE4D4A509FBD!885.entry). Here is some simple code to get the DG created[PS] C:\>Import-CSV dg.csv | foreach {new-distributiongroup -name $_.name -samaccountname $_.SAM -type distribution -org Users} Name DisplayName GroupType PrimarySmtpAddress---- ----------- --------- ------------------Test1 Test1 Universal Test1@domain.comTest2 Test2 Universal Test2@domain.com CSVName,SamTest1,Test1Test2,Test2If you want to create the groups and add the users in the same command let me know. If you want to change any of the default settings from the DG creation let me know.Chris cbfive.com
February 8th, 2010 7:14pm

Hello ccran556,I tried your shell command and it does work fine!!Just 2 more things:1) I need to the following option to be unticked: "Require that all sneders are authenticated"How could I add that in the shell command -> Import-CSV dg.csv | foreach {new-distributiongroup -name $_.name -samaccountname $_.SAM -type distribution -org Users} ???2) How can I add list of users in the DG created? using same tupe of shell commandThanks,G
Free Windows Admin Tool Kit Click here and download it now
February 9th, 2010 11:48am

The below shell command allows to add DG from csv file and untick the "Require that all sneders are authenticated" optionImport-CSV C:\TEST_DG.csv | foreach {new-distributiongroup -name $_.name -samaccountname $_.SAM -type distribution -org Company/DG} | Set-DistributionGroup -RequireSenderAuthenticationEnabled $FalseI just need to had list of users from the list of DG created...Someone can help me out with this??G
February 9th, 2010 1:25pm

The below shell command allows to add DG from csv file and untick the "Require that all sneders are authenticated" option Import-CSV C:\TEST_DG.csv | foreach {new-distributiongroup -name $_.name -samaccountname $_.SAM -type distribution -org Company/DG} | Set-DistributionGroup -RequireSenderAuthenticationEnabled $False I just need to had list of users from the list of DG created... Someone can help me out with this?? G I am not certain on what you are trying to do, if you are trying to untick the require authentication you could run import-csv c:\test_dg.csv | foreach {Set-distributiongroup -identity $_.SAM -RequireSenderAuthenticationEnabled $False}
Free Windows Admin Tool Kit Click here and download it now
February 9th, 2010 2:03pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics