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.
Hash Tables
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.
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.
key/value pairs → looked up by key → used for data or parameter splatting
Validate binding/result and query target state after the operation.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
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.
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
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 · 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.
- 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.
$PSVersionTable— PowerShell edition and versionGet-Command <name>— which cmdlet/function/exe runsGet-Help <cmdlet> -Full— syntax and parametersGet-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)}}.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
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%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.
Quick lookup tables
PowerShell → Hash Tables reference map
Fast lookup boundaries for PowerShell → Hash Tables.
| Item | Meaning | Evidence boundary |
|---|---|---|
| Hashtable | Key/value map | content may be incomplete/unvalidated |
| Ordered dictionary | Preserved insertion order | order does not imply command semantics |
| Splatting | Parameter expansion | binding still occurs at invocation |
| PSCustomObject | Property-oriented object | not identical dictionary semantics |
| Nested config | Structured settings | needs schema/required-key validation |