I found that if you create an array in PowerShell and do this:
$myArray = @()
$myArray += 7
Everytime you execute this statement it creates a NEW array with 7 at the end, and returns the new array and deletes the old array! Basically, we were doing this in a loop of like 10,000 iterations, makes it very slow!
If I use an ArrayList instead, via calling .Add(x), we found it was WAY faster. My question is which code is faster?
$myArrayList.Add(x)
or
$myArrayList += x
Or are they the same? Because our existing code is in the += x format. We hope not to have to change all of the code to the .Add(x) format.