0
0
PowerShellscripting~5 mins

Variable creation with $ in PowerShell - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the $ symbol mean in PowerShell?
The $ symbol is used to create or reference a variable in PowerShell. It tells the shell that what follows is a variable name.
Click to reveal answer
beginner
How do you create a variable named 'name' with the value 'Alice' in PowerShell?
You write: $name = "Alice". This assigns the text 'Alice' to the variable $name.
Click to reveal answer
beginner
Can you use a variable without the $ symbol in PowerShell?
No. In PowerShell, you must use the $ symbol to access or create variables. Without it, PowerShell treats the word as a command or string.
Click to reveal answer
beginner
What happens if you write $number = 5 in PowerShell?
You create a variable named $number and store the number 5 in it. You can use $number later to get the value 5.
Click to reveal answer
beginner
How do you display the value of a variable in PowerShell?
Simply type the variable name with the $ symbol, like $name, and PowerShell will show its value.
Click to reveal answer
What does $var = 10 do in PowerShell?
ACreates a variable named var with value 10
BDeletes the variable var
CPrints 10 to the screen
DCreates a function named var
How do you access the value stored in a variable named 'score'?
A&score
Bscore
C$score
D#score
Which of these is a valid variable name in PowerShell?
A$first_place
B$-score
C$1stPlace
D$score!
What will PowerShell do if you type $greeting without assigning it first?
AShow an error
BShow an empty string
CShow the variable name
DShow nothing
Which symbol is used to create variables in PowerShell?
A%
B#
C&
D$
Explain how to create and use a variable in PowerShell with an example.
Think about how you store and then use a label for a value.
You got /4 concepts.
    What rules should you remember about variable names and usage in PowerShell?
    Consider what characters are allowed and how to call variables.
    You got /4 concepts.