{"id":76493,"date":"2016-01-28T11:59:00","date_gmt":"2016-01-28T11:59:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2016\/01\/28\/powertip-add-number-to-existing-variable-value\/"},"modified":"2019-02-18T09:20:05","modified_gmt":"2019-02-18T16:20:05","slug":"powertip-add-number-to-existing-variable-value","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-add-number-to-existing-variable-value\/","title":{"rendered":"PowerTip: Add number to existing variable value"},"content":{"rendered":"<p><b>Summary<\/b>: Learn how to easily add a number to an existing value stored in a variable and update the value of the variable.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/>&nbsp;How can I use Windows PowerShell to add a number to a value stored in a variable so that I can update the <br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;value in that variable with the number and store the number back into the variable?<\/p>\n<p style=\"margin-left:30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/>&nbsp;Use the&nbsp;<b>+=<\/b>&nbsp;operator. This example adds 3 to the value stored in the&nbsp;<b>$a<\/b>&nbsp;variable and then stores the new <br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;value back into the variable:<\/p>\n<p style=\"margin-left:120px\">PS C:\\&gt; $a = 5<\/p>\n<p style=\"margin-left:120px\">PS C:\\&gt; $a += 3<\/p>\n<p style=\"margin-left:120px\">PS C:\\&gt; $a<\/p>\n<p style=\"margin-left:120px\">8<\/p>\n<p style=\"margin-left:30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\" alt=\" \" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Learn how to easily add a number to an existing value stored in a variable and update the value of the variable. &nbsp;How can I use Windows PowerShell to add a number to a value stored in a variable so that I can update the &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;value in that variable [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[51,356,3,45],"class_list":["post-76493","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-getting-started","tag-powertip","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Learn how to easily add a number to an existing value stored in a variable and update the value of the variable. &nbsp;How can I use Windows PowerShell to add a number to a value stored in a variable so that I can update the &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;value in that variable [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/76493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=76493"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/76493\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=76493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=76493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=76493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}