Creating Distribution Groups
I need to create about 150 distribution groups in Exchange 2007. I would like to use the Exchange Management Shell to accomplish this task. I can create one group at a time using the shell but I would like to know how to create multiple distribution groups at one time. I have all the group names and can put them in any format (excel, csv, comma dilimited)so that they can be uploaded. Thanks for any help.The exact shell command would be great. I ofcourse would fill in the detail.................
March 30th, 2009 10:55pm
Here is the cmdlet to create multiple groups with oneliner...
Import-CSV "C:\NewGroups.csv" | New-DistributionGroup -Name $_.name -OrganizationalUnit "contoso.com/Users" -SAMAccountName $_.SamName -Type $_.Type
Your NewGroups.csv file should be similar to below where you can specify type filed either Distribution or Security depending on the group type you want to create, SAMName will be used for the primary SMTP address prefix also.
Name,SamName,Type
Managers,managers,Distribution
Manager Permission,managersperm,Security
You can also add other various parameters depending on your requirement into cmdlet and in CSV file which are available for New-DistributionGroup cmdlet.
New-DistributionGroup
http://technet.microsoft.com/en-us/library/aa998856.aspx
Amit Tank | MVP - Exchange | MCITP:EMA MCSA:M | http://ExchangeShare.WordPress.com
Free Windows Admin Tool Kit Click here and download it now
March 31st, 2009 8:34am
Can you show me the exact CSV file format for my example. I have been trying for hours to get the script to work and I keep getting error “cannot bind argument to parameter 'Name' because it is null”
I am not concerned with security or managers.
I have over 200 Distribution Groups to create.
Group Name = Group 1234
Type = Global Distribuiton
Primary SMTP = group1234@domain.com
Members = member1,member2,member3,member4
Thanks for any help.
November 20th, 2010 4:57pm
On Sat, 20 Nov 2010 21:52:55 +0000, supra7r wrote:
>Can you show me the exact CSV file format for my example. I have been trying for hours to get the script
"The script"? There's no in your posting. Giving a link to another
thread is no guaranty that what you're running looks like what's in
that link.
>to work and I keep getting error ?cannot bind argument to parameter 'Name' because it is null?
>
>I am not concerned with security or managers.
>
>I have over 200 Distribution Groups to create.
>
>Group Name = Group 1234
>
>Type = Global Distribuiton
Don't use "global" scope. Use "Universal".
>Primary SMTP = group1234@domain.com
>
>Members = member1,member2,member3,member4
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
November 20th, 2010 7:52pm
yes 'universal' i forgot thank you.
do you have any input why i cant get this command to work:
Import-CSV "C:\NewGroups.csv" | New-DistributionGroup -Name $_.name -OrganizationalUnit "contoso.com/Users" -SAMAccountName $_.SamName -Type $_.Type
What would my csv file look like for this?
group name = group 1234
members = user1,user2,user3
The command is complaining about 'name' null.
I need to create several groups with members in each
November 20th, 2010 8:01pm
On Sun, 21 Nov 2010 00:55:49 +0000, supra7r wrote:
>
>
>yes 'universal' i forgot thank you.
>
>do you have any input why i cant get this command to work:
>
>Import-CSV "C:\NewGroups.csv" | New-DistributionGroup -Name $_.name -OrganizationalUnit "contoso.com/Users" -SAMAccountName $_.SamName -Type $_.Type
>
>What would my csv file look like for this?
>
>group name = group 1234
If the column heading in the CSV file is 'group name' then the you
need to use that like this:
. . . -name $_.'group name'
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
November 20th, 2010 8:20pm
Still not working. Here is the command I am running:
Import-CSV "C:\MYCSVfile.csv" | New-DistributionGroup -Name $_.name -OrganizationalUnit "MYDOMAIN.com/Users" -SAMAccountName $_.SamName -Type $_.Type
My CSV file with only 2 groups right now looks like this:
Name,SamName,Type,Members
Group1,group1,Distribution,user1,user2,user3
Group2,group2,Distribution,user4,user5,user6
When I run the command I get this error message:
cannot bind argument to parameter 'Name' because it is null
Were am I wrong?
November 20th, 2010 8:46pm
On Sun, 21 Nov 2010 01:41:02 +0000, supra7r wrote:
>
>
>Still not working. Here is the command I am running:
>
>Import-CSV "C:\MYCSVfile.csv" | New-DistributionGroup -Name $_.name -OrganizationalUnit "MYDOMAIN.com/Users" -SAMAccountName $_.SamName -Type $_.Type
You're missing the "foreach {...}" surrounding the
new-distributiongroup:
Import-CSV "C:\MYCSVfile.csv" | foreach {New-DistributionGroup -Name
$_.name -OrganizationalUnit "MYDOMAIN.com/Users" -SAMAccountName
$_.SamName -Type $_.Type}
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
November 20th, 2010 10:14pm
Doesn't work. I get this repeated several times when trying to run that command:
New-DistributionGroup : Cannot bind argument to parameter 'SamAccountName' beca
use it is null.
At line:1 char:145
+ Import-CSV "C:\groups\NewGroups.csv" | foreach {New-DistributionGroup -Name $
_.name -OrganizationalUnit "MYDOMAIN.local/NY Groups" -SAMAccountName <<<< $_.Sa
mName -Type $_.Type}
+ CategoryInfo : InvalidData: (:) [New-DistributionGroup], Parame
terBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
icrosoft.Exchange.Management.RecipientTasks.NewDistributionGroup
November 21st, 2010 12:25am
On Sun, 21 Nov 2010 01:41:02 +0000, supra7r wrote:
>
>
>Still not working. Here is the command I am running:
>
>Import-CSV "C:\MYCSVfile.csv" | New-DistributionGroup -Name $_.name -OrganizationalUnit "MYDOMAIN.com/Users" -SAMAccountName $_.SamName -Type $_.Type
>
>
>
>My CSV file with only 2 groups right now looks like this:
>
>Name,SamName,Type,Members Group1,group1,Distribution,user1,user2,user3 Group2,group2,Distribution,user4,user5,user6
Try this:
Import-CSV "C:\MYCSVfile.csv" | select name,samname,type
Do all the rows in the CSV have a value in all three columns?
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
November 21st, 2010 1:08am