PowerShell: Assignment Operators
By Xah Lee. Date: .
= → addition
+= → add then assign
-= → substract then assign
*= → times then assign
/= → divide then assign
%= → take remainder then assign
??= → if right-hand-side is not null, assign to left-hand-side
$x = 0
$x += 2
Write-Host $x
Unary, Increment Operators
++ → increment by 1
-- → decrement by 1
- If placed in front of a variable, it increase and assign first, and return the new value.
- If placed after a variable, it return the original variable value first, then increase and assign.
$x = 0
$result = ++$x
Write-Host $x
Write-Host $result
$x = 0
$result = $x++
Write-Host $x
Write-Host $result
PowerShell, variable and assignment