Posted by: Colin Smith
Yesterday I got a call from a coworker who was having an issue with a script. He was looking to get some properties from an object and check the values. The problem is that the properties that he was checking also happened to be a collection of objects. So the problem he was having is that you can not compare the a collection of objects to be equal to one value. After looking at it using the get-member cmdlet, I found that we could make it easier by doing a cmdlet | select | where and then we do not even need the if statements because we are getting the most minimal dataset possible first. Then all we had to do was check to see if the resulting dataset was -eq $null. If so then he wanted to know and if not he did not care about that object. Easy money.
Thing to learn here is that you should always pull back the smallest dataset possible.
Hope that helps.