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:
$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?
You can also try this to get all of the property names
foreach ($property in $result.PSObject.Properties) { $property.Name }
try:
( $result | get-member)[-1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With