Skip to content

Commit 6c07d99

Browse files
OscarFalck17Copilotsdwheeler
authored
Update hashtable documentation with cloning note (#12454)
* Update hashtable documentation with cloning note Added note about cloning hashtables with a single key and provided an example using PowerShell. * Update reference/docs-conceptual/learn/deep-dives/everything-about-hashtable.md Co-authored-by: Copilot <[email protected]> * Editorial changes --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Sean Wheeler <[email protected]>
1 parent 1ebddea commit 6c07d99

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Hashtables are really important in PowerShell so it's good to have a solid understanding of them.
33
ms.custom: contributor-KevinMarquette
4-
ms.date: 06/25/2023
4+
ms.date: 10/22/2025
55
title: Everything you wanted to know about hashtables
66
---
77
# Everything you wanted to know about hashtables
@@ -269,6 +269,16 @@ $environments.Keys.Clone() | ForEach-Object {
269269
}
270270
```
271271

272+
> [!NOTE]
273+
> You can't clone a hashtable containing a single key. PowerShell throws an error. Instead, you
274+
> convert the **Keys** property to an array, then iterate over the array.
275+
276+
```powershell
277+
@($environments.Keys) | ForEach-Object {
278+
$environments[$_] = 'SrvDev03'
279+
}
280+
```
281+
272282
## Hashtable as a collection of properties
273283

274284
So far the type of objects we placed in our hashtable were all the same type of object. I used ages

0 commit comments

Comments
 (0)