Link to home
Start Free TrialLog in
Avatar of Rodders1000
Rodders1000Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Creating groups from a CSV using powershell

I am trying to create set of AD groups from a csv file
It should be straight forward but I am going wrong somewhere.
Can someone point me in the right direction.

I run this ps command
import-csv c:\admin\newgroups.csv | foreach {new-adgroup -Name $_Name -Description $_Description -GroupCategory Security -groupscope Global -Path "OU=Security Groups,dc=company,dc=com"}

MY CSV file contains

Name,Description
"Index - ABC Offshore Ltd","ABC Offshore Ltd"
"Index - DEF Inland","DEF Inland"

I get this error when run
New-ADGroup : Cannot validate argument on parameter 'Name'. The argument is null or empty. Supply an argument that is n
ot null or empty and then try the command again.
At line:1 char:63

If I use the command import-csv c:\admin\newgroups.csv it returns the table of csv contents ok.
ASKER CERTIFIED SOLUTION
Avatar of Neil Russell
Neil Russell
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rodders1000

ASKER

An  hour of ripping my hair out. Stupid DOTs !!

Gracefully hands over the 500.

Thanks Neilsr
Your welcome. Easily done, I have no hair left now due to such stupid mistakes :P
lol. Sorry 1 more thing..

If my title column had a space in it. Is it as simple as $_."Spaced Name" ?