gd6627
asked on
Populate Ad Security groups
Hey Guys - I have a csv file with Group names and descriptions over 100 of them . I need to create these groups and populate description and Note field also set the group scope to Global and the Group type to Security and the managed by property with the owner SAmaccountname in the object ADUC.
Thanks in advance
Thanks in advance
Please define " owner SAmaccountname in the object ADUC"; do you have a column 'Owner' in that csv?
In general, you can use something like this (it uses "splatting" for the arguments, which makes the list easier to handle):
In general, you can use something like this (it uses "splatting" for the arguments, which makes the list easier to handle):
## Target OU:
$path = 'OU=Groups,OU=Whatever,DC=domain,dc=com'
Import-Csv -Path C:\Temp\Groups.csv | ForEach-Object {
$splat = @{
Name = $_.Name
SamAccountName = $_.Name
DisplayName = $_.Name
Description = $_.Description
OtherAttributes = @{info= $_.Notes}
ManagedBy = (Get-ADUser -Identity $_.Owner).DistinguishedName
GroupCategory = 'Security'
GroupScope = 'Global'
Path = $path
}
New-ADGroup @splat
}
ASKER
oBda , yes my colum headers are groupname , description, Notes, OwnerSamaccountname, category, Scope
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok ill give it a try and let you know
i suggest running it in export mode to see the format.... then update your csv to macth the format its expecting and
csvde -i -f <csvname>