<p>What's the best way to initialize an array in PowerShell?</p>

<p>For example, the code</p>

<pre><code>$array = @()
for($i=0; $i -lt 5;$i++)
{
    $array[$i] = $FALSE
}
</code></pre>

<p>generates the error</p>

<pre><code>Array assignment failed because index '0' was out of range.
At H:\Software\PowerShell\TestArray.ps1:4 char:10
+         $array[$ &lt;&lt;&lt;&lt; i] = $FALSE
</code></pre>

The solution I found was to use the New-Object cmdlet to initialize an array of the proper size.
```
```
$array = new-object object[] 5 
for($i=0; $i -lt $array.Length;$i++)
{
    $array[$i] = $FALSE
}
```
```