Arrays are the second most used containers in PowerShell. An array, in simple terms, is a multi-dimensional variable or a variable containing more than one value. The two core components to an array are the index number and the position value. When you use an array, you reference an index number and it will return the position value.

Single-dimension arrays

The following table represents an array with a single dimension:

Index number

Position value


Example 1


Example 2


Example 3


Example 4


Example 5

When you are storing, manipulating, or reading the data in an array, you have to reference the position in the array the data is residing. The numbers populated in the table's Index number column are representative ...

Get Mastering Windows PowerShell Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.