What is array?
An array is a number of items arranged in some specified way.
Like in other languages we can define variable as array and assign or add items or values in it.
In PowerShell defining array is very simple and flexible. You just have items separated by the by the comma.
We will see some examples below.
To create an Array just separate the elements with commas.
Create an array named $myArray containing elements with a mix of data types:
$myPSArray = 5,"ABC",4.6,"Text"
or using explicit syntax:
$myPSArray = @(5,"ABC",4.6,"Text')
To distribute the values back into individual variables:
$var1,$var2,$var3,$var4=$myPSArray
Another example
Powershell is worked on .net framework.
So a PowerShell array is your .NET System.Array.
PowerShell makeit simpler.
It is dead simple to create arrays in PowerShell: separate the items with commas,
and if they are text, wrap them in quotes.
Example
PS C:> $language = "C#", "VB", "Perl", "Java"
PS C:> $language.GetType()
---OutPut------
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
PS C:> $language
---OutPut------
C#
VB
Perl
Java