Pcornel
Windows · PowerShell

Hash Tables

Cheat sheet · https://pcornel.dk/topic.php?topic=3044

Back to the Topic

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.

Remember

  • 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.

First 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

Verify in this order

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

Where it usually breaks

First mismatch in definition/configuration → security context → service/task/process creation → runtime state → output/side effect → event/performance evidence; preserve identity/native error/pre-state before mutation.

PowerShell → Hash Tables reference map

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

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=3044

Confirmation

Confirm action

Continue?