Summary: Learn how to easily add a number to an existing value stored in a variable and update the value of the variable.
How can I use Windows PowerShell to add a number to a value stored in a variable so that I can update the
value in that variable with the number and store the number back into the variable?
Use the += operator. This example adds 3 to the value stored in the $a variable and then stores the new
value back into the variable:
PS C:\> $a = 5
PS C:\> $a += 3
PS C:\> $a
8