I am working on a script to remove a user from every instance of a specific named group across all sites.
In testing, I have created two user objects, one by $group.users.getbyemail(email) and one from $web.ensureuser("domain\user"), and have tried testing for membership in a group using various comparison operators. All return false, though I checked to see that the user was indeed in the group, and the one user object was created with the GetByEmail method from that group.
I would think that $user -in $group.Users or $group.Users -contains $userwould return true, but, clearly, I am mistaken. Any suggestions would be most welcome.
I suppose I can user the GetByEmail method and then test that the user object is not null, but that seems less clean.