PowerShell array performances


I think most of you ever used a PowerShell list like this one :


Let’s have a look at the performances in heavy load :

1..50000 | % {$ClassicList+=$_}

You’ll notice that it take quite a long time to proceed.

Now, let’s try with an other type of list:


Try the same operation with it :

1..50000 | % {$ArrayList.Add($_) | Out-Null}

It’s much faster, let’s have a look at the numbers :


The “ArrayList” is blazing fast, indeed, when you use the “+=” operator, PowerShell, under the hood, create a new object, and put the old and the new one in it.

If you pipe those objects in “Get-Member” :




Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.