Pcornel
Browse topics
Options
Recent
Favorites
Windows · Technical reference

Hash Tables

Direct answer

A PowerShell hash table maps keys to values and is commonly used for configuration data, lookups, calculated structures and parameter splatting. It is not the same as a PSCustomObject even though both can present name/value-like data.

When to use this

Use this topic when building keyed configuration, passing parameter sets through splatting, preserving insertion order, converting between dictionaries and objects, or debugging missing/duplicate keys.

First 30 seconds

1. Create: $h = @{Name='x'; Port=80}.

2. Read: $h['Name'] or $h.Name.

3. Keys: $h.Keys; test: $h.ContainsKey('Name').

4. Ordered: [ordered]@{}.

5. Splatting: Cmd @h.

Operational verification

key/value pairs → looked up by key → used for data or parameter splatting

Evidence · next step

Validate binding/result and query target state after the operation.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Common mistakes
Common traps

Do not assume a hashtable is automatically validated because it is syntactically valid. A typo becomes a different key. Do not rely on ordinary hash-table order for deterministic generated output. Do not confuse dictionary lookup semantics with object property semantics.

Platform / version applicability
Windows execution, automation and observability
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformWindows execution, automation and observability
Scope / prerequisiteUse this topic when building keyed configuration, passing parameter sets through splatting, preserving insertion order,…
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

1 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Verification path Verify boundary

Inspect the actual keys and target command metadata before splatting. For serialized config, validate required fields and types after deserialization. Perform a read-only or WhatIf-like preflight where the target command supports it, then verify target state after invocation.

Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points
  • Hash table keys identify values; iteration order should only be relied on when using an ordered dictionary where order is part of the requirement.
  • Splatting passes entries as parameters but does not validate that those keys match the chosen command/parameter set until binding.
  • A hashtable and a PSCustomObject have different access/member semantics.
  • Key comparison/casing behavior follows the dictionary implementation and PowerShell conventions.
  • Nested hash tables are common for configuration but need schema/validation to avoid silent misspellings.
Key checks
  • $PSVersionTable — PowerShell edition and version
  • Get-Command <name> — which cmdlet/function/exe runs
  • Get-Help <cmdlet> -Full — syntax and parameters
  • Get-ExecutionPolicy -List — execution policy per scope
ReferenceWhat it is1 section · depth on demand

Core model

Hash tables are ideal when lookup by key is more important than positional indexing. They are also a clean way to construct parameter sets dynamically: @params splatting keeps invocation syntax readable and allows conditional parameter inclusion.

ReferenceImportant terms & boundaries2 sections · depth on demand

PowerShell boundary

Use [ordered]@{} when order must be retained. Be explicit when converting between hash tables and PSCustomObject because enumeration, member access and serialization can differ. For configuration use cases, treat key names as a schema and reject unexpected keys before state changes.

In depth

Hash tables store key/value pairs; ordered dictionaries keep insertion order; splatting passes a hash table as parameters.

$cfg = @{ Server = 'sql01'; Port = 1433 }
$cfg.Server; $cfg['Port']; $cfg.Keys
$o = [ordered]@{ Name='app01'; CPU=4 }
$params = @{ ComputerName = 'srv01'; ScriptBlock = { hostname }; ErrorAction = 'Stop' }
Invoke-Command @params
[pscustomobject]$o

Calculated properties in Select-Object use hash tables: @{n='SizeGB';e={[math]::Round($_.Length/1GB,2)}}.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docWindows execution, automation and observability current

Authoritative/upstream documentation reviewed for bounded claims in PowerShell → Hash Tables. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://learn.microsoft.com/en-us/powershell/ · confidence 94%
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
powershell hashtablepowershell hash tablespowershell splattingordered hashtable powershell
Embedded reference data

Quick lookup tables

PowerShell → Hash Tables reference map

Fast lookup boundaries for PowerShell → Hash Tables.

ItemMeaningEvidence boundary
HashtableKey/value mapcontent may be incomplete/unvalidated
Ordered dictionaryPreserved insertion orderorder does not imply command semantics
SplattingParameter expansionbinding still occurs at invocation
PSCustomObjectProperty-oriented objectnot identical dictionary semantics
Nested configStructured settingsneeds schema/required-key validation
Confirmation

Confirm action

Continue?