I've found some interesting behaviour in PowerShell Arrays, namely, if I declare an array as:
$array = @()
And then try to add items to it using the $array.Add("item") method, I receive the following error:
Exception calling "Add" with "1" argument(…
Let's say we have an array of objects $objects. Let's say these objects have a "Name" property.
This is what I want to do
$results = @()
$objects | %{ $results += $_.Name }
This works, but can it be done in a better way?
If …
What's the best way to initialize an array in PowerShell?
For example, the code
$array = @()
for($i=0; $i -lt 5;$i++)
{
$array[$i] = $FALSE
}
generates the error
Array assignment failed because index '0' was out of range.
At H:\Software\…