Solved

Creating Security Groups

Posted on 2013-01-25
2
281 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

744 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

10 Experts available now in Live!

Get 1:1 Help Now