Challenge - 5 Problems
Where-Object Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of filtering numbers greater than 5
What is the output of this PowerShell command?
1..10 | Where-Object { $_ -gt 5 }PowerShell
1..10 | Where-Object { $_ -gt 5 }
Attempts:
2 left
💡 Hint
Remember, Where-Object filters items where the condition is true.
✗ Incorrect
The command filters numbers from 1 to 10, keeping only those greater than 5, which are 6 to 10.
💻 Command Output
intermediate2:00remaining
Filtering strings containing 'a'
What is the output of this PowerShell command?
@('apple','banana','cherry','date') | Where-Object { $_ -like '*a*' }PowerShell
@('apple','banana','cherry','date') | Where-Object { $_ -like '*a*' }
Attempts:
2 left
💡 Hint
The -like operator checks if the string contains the pattern.
✗ Incorrect
Strings containing the letter 'a' are 'apple', 'banana', and 'date'.
📝 Syntax
advanced2:00remaining
Identify the syntax error in filtering
Which option contains a syntax error in using Where-Object to filter even numbers from 1 to 5?
PowerShell
1..5 | Where-Object { $_ % 2 -eq 0 }
Attempts:
2 left
💡 Hint
Check the operator used for comparison.
✗ Incorrect
Option A uses '=' which is assignment, not comparison, causing a syntax error.
🔧 Debug
advanced2:00remaining
Why does this filter return no results?
Given this command:
Why does it return no output?
@('cat','dog','bird') | Where-Object { $_ -ceq 'Cat' }Why does it return no output?
PowerShell
@('cat','dog','bird') | Where-Object { $_ -ceq 'Cat' }
Attempts:
2 left
💡 Hint
Check the case sensitivity of the comparison operator used.
✗ Incorrect
PowerShell's -ceq operator performs case-sensitive string comparisons, so 'cat' does not match 'Cat'.
🚀 Application
expert3:00remaining
Filter processes using Where-Object with multiple conditions
Which command filters processes with CPU usage greater than 100 and process name starting with 's' (case-insensitive)?
Attempts:
2 left
💡 Hint
Use the correct operator for case-insensitive matching and logical AND.
✗ Incorrect
Option D uses '-ilike' for case-insensitive matching and '-and' for combining conditions correctly.