Last week I had to create 100+ security groups for a migration. As lazy as I am I chose Powershell for this job. I will show you what I did.
- First create a .csv file. This file will contain al groupnames you are going to create
- Now start your favorite Powershell editor. I'm using PowerGUI
- Now let's start coding:
# Open CSV with group names
$printers = Import-Csv "printers.csv"
#Path with the OU where the groups will be placed
$printerpath = "OU=Groups,OU=Netherlands,DC=TESTLAB,DC=COM"
# Create Global Security Groups
foreach($entry in $printers) {
$printer = $entry.printers
New-ADGroup -Name "$printer" -GroupCategory Security -GroupScope Global -DisplayName "$printer" -Path $printerpath
}
No comments:
Post a Comment