Ying Li at myITforum.com

PowerShell & System Center

The assignment operators of PowerShell

Here are some examples about PowerShell assignment operators:

“=”

$a = 3

sets the variable to the specified value

“+=”

$a += 2, same as $a = $a + 2

performs the addition operation in the existing value, then assigns the result back to the variable.

“-=”

$a -= 15, same as $a = $a – 15

performs the subtracdtion operation in the existing value, then assigns the result back to the variable.

“*=”

$a = $a * 3, same as $a = $a * 3

multiplies the value of a variable by the specified value or appends to the existing value.

“/=”

$a /= 3, same as $a = $a / 3

divides the value of a variable by the specified value.

“%=”

$a %= 3, same as $a = $a % 3

divides the value of a variable by the specified value and assigns the remainder(modulus) to the variable.

Posted: Jun 26 2007, 02:05 PM by yli628 | with no comments
Filed under:

Comments

No Comments