Great article on working with Collections.
As I noted in my last post, Powershell likes to make arrays.
But it’s been noted that using arrays can be horribly inefficient when it comes to adding or removing items from them, and collections work much better for those operations. The method you normally see to get a collection instead of an array is to instantiate a particular collection type, and then iterate through some objects using the .add() method of the collection to populate it.
In a previous post about script blocks I noted that the Invoke() method of a script block makes the script block return a collection.
If you research that collection type, it’s basically just a generic collection of PS objects. Since it’s a generic collection, it can contain any type of objects so the methods it offers is limited to basic methods for adding, removing, and inserting elements.
Most of the time this is…
View original post 48 more words