Is there an operator, and if so what, to determine equivalence between two SPUser objects in PowerShell?
My instance is looping through a list of sites to replace "domain/John Smith" with "domain/Jane Doe" in a certain site property. It's pulling the SPUser currently in that property, if it's the same as the SPUser "domain/John Smith" then the property gets replaced with the SPUser "domain/Jane Doe".
In this particular instance it's easy enough to to just compare the UserLogin or DisplayName property, but I'm looking for a more sophisticated way to determine equivalency between two users.
Seems like a somewhat late answer, but for the sake of helping anyone stumbling across this issue I can perhaps give some ideas with what I have had to do to find a user and compare certain properties. I have used this example for SharePoint related queries but you can obviously apply the exact principle to other areas.
I get a collection of SiteUsers for my SPWeb, then, in a foreach I iterate through all the users and perform a check: If my user's email address exists in the SPUsers Collection, then add that email address to a SharePoint List. The following is how I would do my comparison:
Although this doesn't directly answer your question it may give you an idea how to use lambda expressions within PowerShell to help you perform quick checks on your data and not only with users. I can think of a few other similar examples if you need.
Below is a small snippet I recently used with this example:
ADD NEW USERS TO THE LIST FROM A CSV FILE