Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Hashtables are really important in PowerShell so it's good to have a solid understanding of them.
ms.custom: contributor-KevinMarquette
ms.date: 06/25/2023
ms.date: 10/22/2025
title: Everything you wanted to know about hashtables
---
# Everything you wanted to know about hashtables
Expand Down Expand Up @@ -269,6 +269,16 @@ $environments.Keys.Clone() | ForEach-Object {
}
```

> [!NOTE]
> You can't clone a hashtable containing a single key. PowerShell throws an error. Instead, you
> convert the **Keys** property to an array, then iterate over the array.

```powershell
@($environments.Keys) | ForEach-Object {
$environments[$_] = 'SrvDev03'
}
```

## Hashtable as a collection of properties

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