PowerShell: Assignment Operators

By Xah Lee. Date: .
$x = 0
$x += 2
Write-Host $x
# 2

Unary, Increment Operators

$x = 0

# increase by one and assign, return the new value
$result = ++$x

Write-Host $x
# 1

Write-Host $result
# 1
$x = 0

# return the value first, then increase by one and assign
$result = $x++

Write-Host $x
# 1

Write-Host $result
# 0