Hej Gents.
I recently acquired The Learn windows Powershell in a month of lunches.
I need a new approach to mastering powershell, im getting better, but I am still at the first few chapters.
Im in the need to create a 1000 AD security groups.
But hours in, im still fighting to get the variables into the script.
I have tried multiple approaches, but im failing for some reason.
Formatted the csv file in multiple ways, currently trying.
CSV:
GroupName,GroupCategory,GroupScope,OU
Groupamexxx,Security,Global,“OU=Groups,OU=Accounts,OU=xxx,DC=live,DC=zxy,DC=local”
Im running this from Powershell ISE as administrator, but my $item.name is not working…
[pre]
$csv = Import-Csv -Path ‘C:\Temp\Create_AD_groups\List3.csv’
forEach ($item in $csv)
{
$Create_group = New-ADGroup -Name ‘$item.Groupname’ -GroupCategory ‘$item.Groupcategory’ -GroupScope ‘$Item.Groupscope’ -Path ‘$Item.OU’ -PassThru –Verbose
}
[/pre]
ERROR
[pre]
New-ADGroup : Cannot bind parameter ‘GroupCategory’. Cannot convert value “$item.Groupcategory” to type “Microsoft.ActiveDirectory.Management.ADGroupCategory”. Error: “Unable to match the identifier name $item.Groupcategory
to a valid enumerator name. Specify one of the following enumerator names and try again:
Distribution, Security”
At line:5 char:68
[/pre]