PowerShell - Finding all of users' group memberships and kicking it out of them
        Posted  
        
            by 
                NirPes
            
        on Server Fault
        
        See other posts from Server Fault
        
            or by NirPes
        
        
        
        Published on 2014-06-04T16:09:03Z
        Indexed on 
            2014/06/04
            21:28 UTC
        
        
        Read the original article
        Hit count: 294
        
as title says, I have to find all the groups that the user is a member of, and deleting its membership from all of them.
I've tried this:
get-adgroup -filter * | where {(Get-ADGroupMember $_ | foreach {$_.PrimarySmtpAdress}) -contains "[email protected]"}
but it doesnt return anything (although THERE ARE some items that have to be returned)
as for the deletion I found no way to do it, could someone give me an example of a code that does this?
Im talking about security groups.
© Server Fault or respective owner