Hash Tables
Hash tables (also called hashtables or dictionaries) are key-value pair collections in PowerShell, similar to associative arrays or dictionaries in other languages.
1. Creating Hash Tables
- Basic syntax:
- Empty hash table:
- Ordered hash table (preserves insertion order):
2. Accessing Values
3. Adding and Modifying
4. Removing Keys
5. Checking Existence
6. Iteration
7. Converting to Objects
8. Nested Hash Tables
9. Common Use Cases
- Configuration storage
- Function parameters (splatting)
- Grouping data
- Lookup tables
10. Performance Notes
- Hash tables provide O(1) average lookup time
- For large datasets, consider using
[System.Collections.Generic.Dictionary[K,V]]for better performance