How to get the name of an object property in powershell?

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:

“myProperty” changes with every different $result.

So does anyone know how I can do this?

Answer:

try:

Source:

How to get the name of an object property in powershell? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply