Creating Security Groups withthe help of Script
Is it possible to create security Grops with the help of script , In our environment we have to create lagre number of security groups on daily basis where we are following naming conventions ex :  xxx-12C-MSFT-VS2008BI-127666-1.0 ,sometimes we have to create almost 20 to 30 security groups whare we are also giving describtion and adding those security groups that to master security groups.  any help will be appreciatable.
September 20th, 2013 2:13am

'Hi,

at first I would request you to  change this thread  Type from "Discussion"  to   "Question" so that you can mark as answer once you get the solution.


Now ,  here is your solution ...........

New-ADGroup -name MasterGroup -Description "This is master Group" -GroupScope Global -GroupCategory Security
$masterG=Get-ADGroup "masterGroup"

$gName="Group" # if you want other naming convention , change here 

$num=Read-Host "Number of Groups you want to create "

for($i=1;$i -le $num; $i++)
{

new-adgroup -Name "$gname $i" -Description " This group is member of Master Group"  -GroupCategory Security -GroupScope Global

Add-ADGroupMember -Identity $masterG -Members "$gname $i"

}

This will create a Master group named 'MasterGroup' and then will create  the group in the naming conventions like 'Group 1' , "Group 2 " ........ and so on based on the number of your input you want to create group  and then finally add these group to MasterGroup.


Hope , it helps you.

Free Windows Admin Tool Kit Click here and download it now
September 20th, 2013 3:12am

HI tarique

thanks for your solution ,i will try this and let you know,

i have a doubt, if we have to fill same discribtion on all security groups then what modification require in the script.

September 20th, 2013 3:23am

Hi ,

 we have included the description as well , in the -Descripton parameter => replace your own descripton here

One more thing :

Don't forget to  import ActiveDirectory module while you run this script in PowerShell.

Import-Module ActiveDirectory

new-adgroup -Name "$gname $i" -Description " This group is member of Master Group"  -GroupCategory Security -GroupScope Global

Free Windows Admin Tool Kit Click here and download it now
September 20th, 2013 4:42am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics