Does Powershell have an "eval" equivalent? Is there a better way to see a list of properties and val

Posted by glenatron on Stack Overflow See other posts from Stack Overflow or by glenatron
Published on 2010-03-17T17:54:46Z Indexed on 2010/03/17 20:51 UTC
Read the original article Hit count: 886

Filed under:
|

I'm doing a bit of Powershell scripting ( for the first time ) to look at some stuff in a Sharepoint site and what I would like to be able to do is to go through a list of properties of an object and just output their values in a "property-name = value" kind of format.

Now I can find the list of elements using this:

$myObject | get-member -membertype property

Which will return a list of all the properties in a very clear and readable fashion. But what I need is to find a value for those properties.

In some scripting languages I could have a kind of eval( "$myObject.$propertyName" ) call - where I have extracted $propertyName from the get-member output - and have it evaluate the string as code, which for the kind of quick-and-dirty solution I need would be fine.

Does this exist in Powershell or is there a more convenient way to do it? Should I be using reflection instead?

© Stack Overflow or respective owner

Related posts about powershell

Related posts about reflection