?
Solved

Populating AD Security Groups based on AD attribute

Posted on 2013-06-18
3
Medium Priority
?
1,527 Views
Last Modified: 2013-06-19
Hi Experts,

Is there a way to script the following:

If user is member of a certain department (AD Attribute) then populate a certain security group i.e. make the user a member of that security group?

Domain is Windows 2008 R2

TIA
0
Comment
Question by:abhijitm00
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 39257209
Try somethign lke..
Get-ADuser -filter {Department -eq "Marketing"} | %{Add-ADGroupMember "Marketing Group" $_.SamAccountName}

Open in new window

0
 

Author Comment

by:abhijitm00
ID: 39257795
Thanks Subsun, this seems to work. Is there a way to restrict this to a certain OU?
0
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 39257819
Try..
Get-ADUser -SearchBase 'OU=UserAccounts,DC=contoso,DC=local' -filter {Department -eq "Marketing"} | %{Add-ADGroupMember "Marketing Group" $_.SamAccountName}

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…
Suggested Courses

770 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