The Multifunctioning DBA

Apr 13 2010   5:00PM GMT

Powershell: AD Groups

Colin Smith Colin Smith Profile: Colin Smith

Two weeks ago was part of implementing a large upgrade in one of our Sybase environments. In order for this upgrade to be succesful we had to do some work in some AD groups. We needed to find all the users that would need to be a member of the new group that we were creating and take them out of the old group. The old group still needed to be around though, for users that were not affected by the upgrade. I knew that I would we had one group, that all the affected users were already a member of, so I could copy that groups members into the new group. However, if I did not also take these users out of the old group, then nothing would work. So here is what I did.



$users = Get-QADGroupMember "GroupA" foreach ($user in $users){ $user | Remove-QADGroupMember "GroupB" $user | Add-QADGroupMember "GroupC"

Keep in mind that you will need the Quest AD cmdlets installed in order for this to work.

 

Let me know if you have any questions.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: