Skip to content

Commit 49f87b7

Browse files
authored
Update everything-about-pscustomobject.md
Added how to get name or value by index-number.
1 parent f3a9fee commit 49f87b7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

reference/docs-conceptual/learn/deep-dives/everything-about-pscustomobject.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ You can then access and use the values like you would a normal object.
4141
$myObject.Name
4242
```
4343

44+
To get name or value by index-number
45+
46+
```powershell
47+
$myObject.psobject.properties.Name[2]
48+
$myObject.psobject.properts.Value[2]
49+
```
50+
4451
### Converting a hashtable
4552

4653
While I am on the topic, did you know you could do this:
@@ -129,6 +136,13 @@ We can get this same list off of the `psobject` property too.
129136
$myobject.psobject.Properties.Name
130137
```
131138

139+
Or to get all values
140+
141+
```powershell
142+
$myobject.psobject.Properties.Value
143+
```
144+
145+
132146
> [!NOTE]
133147
> `Get-Member` returns the properties in alphabetical order. Using the member-access operator to
134148
> enumerate the property names returns the properties in the order they were defined on the object.

0 commit comments

Comments
 (0)