Remove all member of a OU from all Groups

by pumabaer at 2013-05-01 00:12:37

Is there nobody here who can help me to solve my Question ?

Q: I wan´t to remove all Members of a OU from all Groups they are Member of, I tried this:

$User = Get-ADUser -Filter * -Searchbase "OU=test,OU=testtest,OU=test,DC=test,DC=test"
Get-ADPrincipalGroupMembership $User| % {Remove-ADPrincipalGroupMembership $User -Confirm:0 -MemberOf $_}

and some other things.
Can anybody help me to find out what is wrong.

Thanks so much Stefan