Rodders1000
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Your welcome. Easily done, I have no hair left now due to such stupid mistakes :P
ASKER
lol. Sorry 1 more thing..
If my title column had a space in it. Is it as simple as $_."Spaced Name" ?
If my title column had a space in it. Is it as simple as $_."Spaced Name" ?
ASKER
Gracefully hands over the 500.
Thanks Neilsr