Accessing values of object properties in PowerShell

后端 未结 3 1234
旧巷少年郎
旧巷少年郎 2020-12-31 05:06

I\'m going through an array of objects and I can display the objects fine.

$obj

displays each object in my foreach loop fine. I\'m trying t

3条回答
  •  旧巷少年郎
    2020-12-31 05:48

    Operator precedence interprets that in the following way:

    ($obj.$_).Name
    

    which leads to nothing because you want

    $obj.($_.Name)
    

    which will first evaluate the name of a property and then access it on $obj.

提交回复
热议问题