Arrays
suggest changeArray declaration in PowerShell is almost the same as assigning any other variable: you use a $name = syntax. Separate the items with commas (,):
$myArrayOfInts = 1,2,3,4
$myArrayOfStrings = "1","2","3","4"
Adding to an array
Adding to an array is as simple as using the + operator. This creates a new array; it does not change the original object in place:
$myArrayOfInts = $myArrayOfInts + 5
# now contains 1,2,3,4, and 5
Combining arrays together
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
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents