The Multifunctioning DBA

Apr 29 2011   4:12PM GMT

Powershell Data Sets

Colin Smith Colin Smith Profile: 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.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: