View Single Post
Old 06-12-2008   #3 (permalink)
JSC


 
 

Re: Remove Users From All Groups

Thanks Shay. RichS pointed me in the right direction. And with your help I
think I can customize it to work with the removal of the persons Exchange
mailbox as well. Thanks!

"Shay Levi" wrote:
Quote:

>
>
> Remove -whatIf to execute the removal:
>
>
> foreach ($user in (get-content users.txt)){
> (get-qaduser $user).memberof | Get-QADGroup | where {$_.name -ne "domain
> users"} | Remove-QADGroupMember -member $user -whatif
> }
>
>
>
>
> ---
> Shay Levi
> $cript Fanatic
> http://scriptolog.blogspot.com
>
Quote:

> > I always get help/assistance in posting here so I am here again.
> >
> > With the Quest AD-CMDlets, I can get a individuals group membership by
> > running:
> > (get-qaduser USERNAME@xxxxxx).memberof | get-qadgroup | ft
> > name
> > What if I wanted to read in a list of usersnames from a file, and
> > remove the user from all groups they are currently a member of.
> >
> > (with the exception of domain users which I think isn't even printed
> > in the command I list above because it is understood that everybody is
> > a member of that group)
> >
> > I am thinking thwere would be two loops, one to read in the users, and
> > inside that loop another one that would go through each group that
> > person is a member of and remove them from it.
> >
>
>
>
My System SpecsSystem Spec