powershell new element to array code example
Example 1: powershell arry initialize add
$al = New-Object System.Collections.ArrayList
for($i=0; $i -lt 5; $i++)
{
$al.Add($i)
}
Example 2: powershell add element to array
PS C:\> $colorPicker = @('blue','white','yellow','black')
PS C:\> $colorPicker = $colorPicker + 'orange'
PS C:\> $colorPicker
blue
white
yellow
black
orange
PS C:\> $colorPicker += 'brown'
PS C:\> $colorPicker
blue
white
yellow
black
orange
brown