PowerShell: Array, Set Item

By Xah Lee. Date: .

Set Array Element via Syntax

$x = 1, 2, 3
$x[0] = "b"
$x
# b 2 3

Method: SetValue

or use method SetValue(val, index)

$x = 1, 2, 3
$x.SetValue("b",0)
$x

Delete Item

It's not easy to delete array item in PowerShell. Array data structure is not designed to change size. Instead of delete, just replace the item by $null

PowerShell: Array