Forked from a gist by @KevinBlumenfeld (Kevin Blumenfeld) originally credited to @MarkEKraus (Mark Kraus), author of Get-PowerShellBlog
A quick reference for choosing the right collection type in PowerShell. This guide includes best practices and examples for Arrays, Lists, HashTables, and more, demonstrating how to leverage .NET classes for enhanced functionality. PowerShell was originally designed to "expose the power of .NET in an admin-friendly way"[^dotNetPowerShell], providing direct integration with .NET classes and methods within Powershell.
- Use
Arraysif you know the element types and have a fixed length and known-up-front collection size that absolutely, certifiably, categorically WILL NOT CHANGE. - Use
ArrayListif you have an unknown collection size wit