Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

PowerShell, check for user in group

$
0
0

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.


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>