Solved

Populating AD Security Groups based on AD attribute

Posted on 2013-06-18
3
1,175 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
  • 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 500 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

Join & Write a Comment

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

747 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

7 Experts available now in Live!

Get 1:1 Help Now