Question:
I know I can use get-member to get all the properties of an object but I’m going through a list of objects and I’m interested in the very last property whose name keeps changing. To automate my script, I’m trying to get the name of that last property but I’m not sure how.
Let’s say I have:
1 2 3 4 5 6 7 8 9 10 |
$result | get-member Name MemberType Definition ---- ---------- ---------- something something something . . . myProperty NoteProperty System.Object[] |
“myProperty” changes with every different $result.
So does anyone know how I can do this?
Answer:
try:
1 2 |
( $result | get-member)[-1] |