Skip to content

Commit

Permalink
(GH-10505) Add note on property name ordering (#10507)
Browse files Browse the repository at this point in the history
Prior to this change, the "Enumerating property names" section
in _Everything you wanted to know about PSCustomObject_ didn't
clarify that the results from using `Get-Member` and the
member-access operator to enumerate property names differs.

`Get-Member` returns the properties in alphabetical order while
member-access returns them in the order they were defined on the
object.

This change:

- adds a note to clarify this difference.
- Resolves #10505
- Fixes AB#169145
  • Loading branch information
michaeltlombardi authored Oct 11, 2023
1 parent a80a275 commit af3a44c
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: PSCustomObject is a simple way to create structured data.
ms.custom: contributor-KevinMarquette
ms.date: 06/07/2023
ms.date: 10/11/2023
title: Everything you wanted to know about PSCustomObject
---
# Everything you wanted to know about PSCustomObject
Expand Down Expand Up @@ -129,6 +129,10 @@ We can get this same list off of the `psobject` property too.
$myobject.psobject.properties.name
```

> [!NOTE]
> `Get-Member` returns the properties in alphabetical order. Using the member-access operator to
> enumerate the property names returns the properties in the order they were defined on the object.
### Dynamically accessing properties

I already mentioned that you can access property values directly.
Expand Down

0 comments on commit af3a44c

Please sign in to comment.