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?
✗ Incorrect
The
-ne operator means 'not equal' and returns True if values differ.What does
7 -gt 5 return?✗ Incorrect
-gt means 'greater than'. 7 is greater than 5, so it returns True.If
$a = 4 and $b = 4, what does $a -eq $b return?✗ Incorrect
Since both values are equal,
-eq returns True.Which operator would you use to check if a number is less than another?
✗ Incorrect
-lt means 'less than' and checks if left value is smaller.What does
10 -ne 10 return?✗ Incorrect
Since both values are equal,
-ne returns False.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.