Solved

Populating AD Security Groups based on AD attribute

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

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…

696 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