Array declaration in Powershell is almost the same as instantiating any other variable, i.e. you use a $name =
syntax. The items in the array are declared by separating them by commas(,
):
$myArrayOfInts = 1,2,3,4
$myArrayOfStrings = "1","2","3","4"
Adding to an array is as simple as using the +
operator:
$myArrayOfInts = $myArrayOfInts + 5
//now contains 1,2,3,4 & 5!
Again this is as simple as using the +
operator
$myArrayOfInts = 1,2,3,4
$myOtherArrayOfInts = 5,6,7
$myArrayOfInts = $myArrayOfInts + $myOtherArrayOfInts
//now 1,2,3,4,5,6,7