0
0
PowerShellscripting~5 mins

Assignment operators in PowerShell - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the assignment operator '=' do in PowerShell?
It assigns the value on the right side to the variable on the left side. For example, $x = 5 sets the variable $x to 5.
Click to reveal answer
beginner
How does the '+=' operator work in PowerShell?
It adds the value on the right to the current value of the variable on the left and then assigns the result back to that variable. For example, $x += 3 means $x = $x + 3.
Click to reveal answer
beginner
What is the difference between '=' and '-=' operators?
= assigns a new value to a variable. -= subtracts the right value from the variable's current value and assigns the result back. For example, $x -= 2 means $x = $x - 2.
Click to reveal answer
intermediate
Can you use '*=' operator in PowerShell? What does it do?
Yes, *= multiplies the variable's current value by the right value and assigns the result back. For example, $x *= 4 means $x = $x * 4.
Click to reveal answer
intermediate
Explain how the '/=' operator works with an example.
The /= operator divides the variable's current value by the right value and assigns the result back. For example, $x /= 2 means $x = $x / 2. It works with numbers.
Click to reveal answer
What does the operator '+=' do in PowerShell?
AAdds the right value to the variable and updates it
BAssigns the right value to the variable without change
CSubtracts the right value from the variable
DDivides the variable by the right value
Which operator assigns a new value to a variable?
A*=
B=
C-=
D/=
If $x = 10, what is the value of $x after $x -= 4?
A6
B14
C4
D40
What will $x *= 3 do if $x is 5?
ASet $x to 2
BSet $x to 8
CSet $x to 15
DSet $x to 53
Which operator divides the variable by a value and updates it?
A+=
B*=
C-=
D/=
Describe how assignment operators like '=', '+=', and '-=' work in PowerShell with simple examples.
Think about how you update a variable's value step by step.
You got /4 concepts.
    Explain why assignment operators are useful in scripting and how they help automate tasks.
    Consider how you might keep track of counts or totals in a script.
    You got /4 concepts.