Solved

Creating Security Groups

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

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…
Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

822 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