How to select a user and remove all groups they are a member of using Powershell (with Quest)?

Posted by Don on Server Fault See other posts from Server Fault or by Don
Published on 2012-06-27T19:45:55Z Indexed on 2012/07/09 9:17 UTC
Read the original article Hit count: 135

Filed under:

I've read quite a bit online about this and thought I had found a solution, but it doesn't seem to be working like I would expect.

I am wanting to get a user based on the username I input, then remove all groups that it is a member of. Basically the same thing as going into ADUC, selecting the user, selecting the Member Of tab, highlighting everything (except domain users of course) and selecting remove.

Here's the command I'm trying to use:

Get-QADUser -Name $username | Remove-QADMemberOf -RemoveAll

Others have said online that it works for them, but so far it hasn't for me. It doesn't give an error, it accepts the command just fine, but when I look in ADUC, the groups are still there for the user.

Any suggestions as to what I may be doing wrong?

Executing from Windows 7 with domain admin rights, Exchange cmdlets and Quest snapin loaded.

Thanks!

© Server Fault or respective owner

Related posts about powershell