Assignment operators
Assignment operators are used to give values to variables. The assignment operators that are available are as follows:
- Assign:
=
- Add and assign:
+=
- Subtract and assign:
-=
- Multiply and assign:
*=
- Divide and assign:
/=
- Remainder and assign:
%=
As with the arithmetic operators, add and assign may be used with strings, arrays, hashtables, and many more. Multiply and assign may be used with strings and arrays.
Assign, add and assign, and subtract and assign
The assignment operator (=
) is used to assign values to variables and properties; for example, it may be used to assign a value to a variable:
$variable = 'some value'
Alternatively, the PowerShell console window title (or Windows Terminal tab title) might be changed by assigning a new value to the WindowTitle
property:
$host.UI.RawUI.WindowTitle = 'PowerShell window'
The add and assign operator (+=
) operates in a similar...