Skip to content

Commit 3cb0771

Browse files
(AB-168933) Clarify Length and Count for PSCustomObject (MicrosoftDocs#10512)
Prior to this change, the documentation note for the **Length** and **Count** properties of **PSCustomObjects** created by casting a hashtable indicated that, for Windows PowerShell, those properties don't exist on the object and accessing them returns `$null`. However, in PowerShell, those members exist and return a value of `1`. This change: - Updates the note to indicate the changed behavior. - Fixes AB#168933
1 parent 861ae1e commit 3cb0771

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

reference/5.1/Microsoft.PowerShell.Core/About/about_PSCustomObject.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Explains the differences between the [psobject] and [pscustomobject] type accelerators.
33
Locale: en-US
4-
ms.date: 12/05/2022
4+
ms.date: 10/11/2023
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_pscustomobject?view=powershell-5.1&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about PSCustomObject
@@ -219,7 +219,7 @@ have subtle side effects.
219219
## Notes
220220

221221
In Windows PowerShell, objects created by casting a **Hashtable** to
222-
`[pscustomobject]` do not have the **Length** or **Count** properties.
222+
`[pscustomobject]` don't have the **Length** or **Count** properties.
223223
Attempting to access these members returns `$null`.
224224

225225
For example:
@@ -236,6 +236,10 @@ PS> $object.Count
236236
PS> $object.Length
237237
```
238238

239+
Starting in PowerShell 6, objects created by casting a **Hashtable** to
240+
`[pscustomobject]` always have a value of `1` for the **Length** and **Count**
241+
properties.
242+
239243
## See also
240244

241245
- [about_Object_Creation][01]

reference/7.2/Microsoft.PowerShell.Core/About/about_PSCustomObject.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Explains the differences between the [psobject] and [pscustomobject] type accelerators.
33
Locale: en-US
4-
ms.date: 12/05/2022
4+
ms.date: 10/11/2023
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_PSCustomObject?view=powershell-7.2&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about PSCustomObject
@@ -214,7 +214,7 @@ have subtle side effects.
214214
## Notes
215215

216216
In Windows PowerShell, objects created by casting a **Hashtable** to
217-
`[pscustomobject]` do not have the **Length** or **Count** properties.
217+
`[pscustomobject]` don't have the **Length** or **Count** properties.
218218
Attempting to access these members returns `$null`.
219219

220220
For example:
@@ -231,6 +231,10 @@ PS> $object.Count
231231
PS> $object.Length
232232
```
233233

234+
Starting in PowerShell 6, objects created by casting a **Hashtable** to
235+
`[pscustomobject]` always have a value of `1` for the **Length** and **Count**
236+
properties.
237+
234238
## See also
235239

236240
- [about_Object_Creation][01]

reference/7.3/Microsoft.PowerShell.Core/About/about_PSCustomObject.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Explains the differences between the [psobject] and [pscustomobject] type accelerators.
33
Locale: en-US
4-
ms.date: 12/05/2022
4+
ms.date: 10/11/2023
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_pscustomobject?view=powershell-7.3&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about PSCustomObject
@@ -214,7 +214,7 @@ have subtle side effects.
214214
## Notes
215215

216216
In Windows PowerShell, objects created by casting a **Hashtable** to
217-
`[pscustomobject]` do not have the **Length** or **Count** properties.
217+
`[pscustomobject]` don't have the **Length** or **Count** properties.
218218
Attempting to access these members returns `$null`.
219219

220220
For example:
@@ -231,6 +231,10 @@ PS> $object.Count
231231
PS> $object.Length
232232
```
233233

234+
Starting in PowerShell 6, objects created by casting a **Hashtable** to
235+
`[pscustomobject]` always have a value of `1` for the **Length** and **Count**
236+
properties.
237+
234238
## See also
235239

236240
- [about_Object_Creation][01]

reference/7.4/Microsoft.PowerShell.Core/About/about_PSCustomObject.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Explains the differences between the [psobject] and [pscustomobject] type accelerators.
33
Locale: en-US
4-
ms.date: 12/05/2022
4+
ms.date: 10/11/2023
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_pscustomobject?view=powershell-7.4&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about PSCustomObject
@@ -214,7 +214,7 @@ have subtle side effects.
214214
## Notes
215215

216216
In Windows PowerShell, objects created by casting a **Hashtable** to
217-
`[pscustomobject]` do not have the **Length** or **Count** properties.
217+
`[pscustomobject]` don't have the **Length** or **Count** properties.
218218
Attempting to access these members returns `$null`.
219219

220220
For example:
@@ -231,6 +231,10 @@ PS> $object.Count
231231
PS> $object.Length
232232
```
233233

234+
Starting in PowerShell 6, objects created by casting a **Hashtable** to
235+
`[pscustomobject]` always have a value of `1` for the **Length** and **Count**
236+
properties.
237+
234238
## See also
235239

236240
- [about_Object_Creation][01]

0 commit comments

Comments
 (0)