How it works...
This recipe was aimed at initializing and adding content to an array. We used two cases here. In the first case, we added the name of one process to a variable, and tried to add five more to it. However, the value assigned to the variable at the end of it turned out to be a string, not an array as we may have expected. This happened because the + operator, when used with strings, concatenates strings. $Process was a string; we never told PowerShell that we wanted an array.
In the third step, we initialized an array using @(). And then, we used the += assignment operator to add content to the now-empty array. Remember that you must use the += assignment operator when adding content to the empty array; using the = operator will ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access