February 2019
Intermediate to advanced
626 pages
15h 51m
English
There are a number of ways to create arrays. An empty array (containing no elements) can be created as follows:
$myArray = @()
An empty array of a specific size may be created using the New object. Using [] after the name of the type denotes that it is an array, and the number following sets the array size:
$myArray = New-Object Object[] 10 # 10 objects $byteArray = New-Object Byte[] 100 # 100 bytes $ipAddresses = New-Object IPAddress[] 5 # 5 IP addresses
An array with a few strings in it can be created as follows:
$myGreetings = "Hello world", "Hello sun", "Hello moon"
Or it can be created as follows:
$myGreetings = @("Hello world", "Hello sun", "Hello moon")
An array may be spread over multiple lines in either the ...
Read now
Unlock full access