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'.
What is missing from the syntax to get these created.?
Best Answer
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:
And the powershell command needs to specify the arguments as follows:
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:
There's more information in the technet exchange reference guide if you need it.