Assigning Variables

by Nov 2, 2008

With PowerShell, you can assign values to multiple variables. For example, to initialize three variables to the same default value, use this:

$a = $b = $c = 0

To assign different values to a number of variables, use the comma separator.

$a, $b, $c = 1,2,3

To switch variable content, try this:

$a, $b = $b, $a