0

I'm trying to add some new distribution lists to exchange using the below.

 C:\>Import-CSV "c:\external.csv" | foreach {New-DistributionGroup -Name $_.name -Type $_.Type}

I've created a CSV file in the format

Name,         Type
Inter_Partners, Distribution

When I run the above command I get the following:

A positional parameter cannot be found that accepts argument '-Type'.

enter image description here

What is missing from the syntax to get these created.?

1 Answer 1

2

I can't test this since I'm not at work today but you're missing the parameters in both the csv and the cmdlet, as far as I can see, so you're just chucking a bunch of data at the cmdlet without specifying what to do with it.

Your CSV file needs to look something like this:

Name, Type
Group1, Distribution
Group2, Distribution

And the powershell command needs to specify the arguments as follows:

Import-CSV "c:\example.csv" | foreach {New-DistributionGroup -Name $_.Name -Type $_.Type}

I actually logged into a test system at work to check my thoughts in response to your continuing problems. Here are the results of running the statement I'm using against my example .csv file for me:

[PS] C:\Windows\system32>import-csv "e:\test.txt" | foreach {New-DistributionGroup -Name $_.Name -Type $_.Type}

Name                          DisplayName                   GroupType                     PrimarySmtpAddress
----                          -----------                   ---------                     ------------------
test1                         test1                         Universal                     [email protected]
test2                         test2                         Universal                     [email protected]

There's more information in the technet exchange reference guide if you need it.

3
  • @JJJJNR in that case, please edit your question to show the results of import-csv "c:\whatever-the-path-is-to-your-file\file.csv
    – Rob Moir
    Commented Sep 22, 2014 at 11:10
  • please update your question to show exactly what command you're typing now, plus the results of running import-csv against your current csv file.
    – Rob Moir
    Commented Sep 22, 2014 at 11:25
  • 1
    @JJJJNR the only suggestion I've got is remove the leading spaces from " Type" in your .csv file, and carefully review how you've typed in the cmdlet and parameters. I've just remotely logged into one of the exchange servers at work and tested the csv and script in my answer, and it created the groups ok.
    – Rob Moir
    Commented Sep 22, 2014 at 11:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .