Accessing values of object properties in PowerShell

后端 未结 3 1233
旧巷少年郎
旧巷少年郎 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:57

    Once you iterate over the properties inside the foreach, they become available via $_ (current object symbol). Just like you printed the names of the properties with $_.Name, using $_.Value will print their values:

    $obj.psobject.properties | % {$_.Value}
    

提交回复
热议问题