Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Add number to existing variable value

$
0
0

Summary: Learn how to easily add a number to an existing value stored in a variable and update the value of the variable.

Hey, Scripting Guy! Question 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?

Hey, Scripting Guy! Answer 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


Viewing all articles
Browse latest Browse all 3333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>