An array contains a set of objects of the same type. Each entry in the array is called an element, and each element has an index (position). Indexing in an array starts from 0.
Arrays are an important part of PowerShell. When the return from a command is assigned to a variable, an array will be the result if the command returns more than one object. For example, the following command will yield an array of objects:
$processes = Get-Process
Array type
In PowerShell, arrays are, by default, given the System.Object[] type (an array of objects where [] is used to signify that it is an array).
Why System.Object?
All object instances are derived from a .NET type or class, and, in .NET, every object instance is derived from System.Object (including strings and integers). Therefore, a System.Object array in PowerShell can hold just about anything.
In PowerShell, arrays are, by default, given the System.Object[] type (an array of objects where [] is used to signify that it is an array).
Why System.Object?
All object instances are derived from a .NET type or class, and, in .NET, every object instance is derived from System.Object (including strings and integers). Therefore, a System.Object array in PowerShell can hold just about anything.
Arrays in PowerShell (and ...