Solved

Creating Security Groups

Posted on 2013-01-25
2
283 Views
Last Modified: 2013-01-25
I have this script that I have been working on. I am now stuck and could use some help.

Add-PSSnapin Quest.ActiveRoles.ADManagement

$SourceGroup=Read-Host "What is the Software Distribution Group?"

$SchoolGroups= 
    "ALT_$SourceGroup",
    "BHS_$SourceGroup"

$SchoolOUs= 
    "OU=ALT Applications,OU=ALT Groups,OU=Altama Elementary School,OU=Elementary Schools,OU=Domain Sites,DC=GCBE,DC=local", 
    "OU=BHS Applications,OU=BHS Groups,OU=Brunswick High School,OU=High Schools,OU=Domain Sites,DC=GCBE,DC=local"

Foreach ($SchoolGroup in $SchoolGroups) {
New-QADGroup -Name $SchoolGroup -ParentContainer $SchoolOUs -SamAccountName $SchoolGroups -GroupType Security -GroupScope Global
Add-QADGroupMember $SourceGroup $SchoolGroups }

Open in new window


My goal is to prompt for a security group and then have the script create nested sub groups for each group listed in $SchoolGroups and to create them in their corresponding OU ($SchoolOUs).

I am then wanting to add the newly created groups into the $sourcegroup.
0
Comment
Question by:Joseph Moody
2 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 38819178
Try this..
Add-PSSnapin Quest.ActiveRoles.ADManagement
$SourceGroup=Read-Host "What is the Software Distribution Group?"
$SchoolGroups= 
    "ALT_$SourceGroup",
    "BHS_$SourceGroup"

Foreach ($SchoolGroup in $SchoolGroups) {
If ($SchoolGroup -match "^ALT_") 
	{$SchoolOUs= "OU=ALT Applications,OU=ALT Groups,OU=Altama Elementary School,OU=Elementary Schools,OU=Domain Sites,DC=GCBE,DC=local"}
ElseIf ($SchoolGroup -match "^BHS_") 
	{$SchoolOUs= "OU=BHS Applications,OU=BHS Groups,OU=Brunswick High School,OU=High Schools,OU=Domain Sites,DC=GCBE,DC=local"}

New-QADGroup -Name $SchoolGroup -ParentContainer $SchoolOUs -SamAccountName $SchoolGroup -GroupType Security -GroupScope Global
}

#After creating the groups you can add the members..
$SchoolGroups | %{Add-QADGroupMember $_ $SchoolGroups}

Open in new window

0
 
LVL 22

Author Closing Comment

by:Joseph Moody
ID: 38819405
Just what I needed!

I changed the last line to Add-QADGroupMember $SourceGroup $SchoolGroups
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
"Migrate" an SMTP relay receive connector to a new server using info from an old server.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now