数组

创建

$A = 22,5,10,8,12,9,80

访问

$a[0]

遍历

$a = 0..9
foreach ($element in $a) {
  $element
}

下标遍历

$a = 0..9
for ($i = 0; $i -le ($a.length - 1); $i += 2) {
  $a[$i]
}

类和对象

class Device {
    [string]$Brand
    [string]$Model
    [string]$VendorSku
}

$device = [Device]::new()
$device.Brand = "Microsoft"
$device.Model = "Surface Pro 4"
$device.VendorSku = "5072641000"

$device

可以如下方式构造对象:

[Device]$surface = [Device]::new("Microsoft", "Surface Pro 4", "5072641000")