0
0
PowerShellscripting~5 mins

Comparison operators (-eq, -ne, -gt, -lt) in PowerShell - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the PowerShell operator -eq do?
The -eq operator checks if two values are equal. It returns True if they are the same, otherwise False.
Click to reveal answer
beginner
Explain the use of -ne in PowerShell.
The -ne operator means 'not equal'. It returns True if two values are different, and False if they are the same.
Click to reveal answer
beginner
What is the difference between -gt and -lt in PowerShell?
-gt means 'greater than' and checks if the left value is bigger than the right. -lt means 'less than' and checks if the left value is smaller than the right.
Click to reveal answer
beginner
How would you check if a variable $x is greater than 10 in PowerShell?
Use the operator -gt: $x -gt 10. This returns True if $x is more than 10.
Click to reveal answer
beginner
What will 5 -lt 3 return in PowerShell and why?
It returns False because 5 is not less than 3.
Click to reveal answer
Which operator checks if two values are NOT equal in PowerShell?
A-eq
B-gt
C-ne
D-lt
What does 7 -gt 5 return?
ANull
BTrue
CError
DFalse
If $a = 4 and $b = 4, what does $a -eq $b return?
ATrue
BFalse
CNull
DError
Which operator would you use to check if a number is less than another?
A-ne
B-gt
C-eq
D-lt
What does 10 -ne 10 return?
AFalse
BTrue
CError
DNull
Describe how to use PowerShell comparison operators to compare two numbers.
Think about how you compare numbers in daily life: equal, not equal, bigger, smaller.
You got /4 concepts.
    Give an example of a PowerShell command using -gt and explain what it does.
    Imagine checking if your age is greater than 18.
    You got /3 concepts.