Challenge - 5 Problems
Pipeline Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this PowerShell pipeline?
Consider the following PowerShell command pipeline. What will be the output?
PowerShell
1..5 | Where-Object { $_ % 2 -eq 0 } | ForEach-Object { $_ * 3 }
Attempts:
2 left
💡 Hint
Think about which numbers pass the filter and what happens next.
✗ Incorrect
The pipeline filters numbers 1 to 5 to only even numbers (2 and 4), then multiplies each by 3, resulting in 6 and 12.
🧠 Conceptual
intermediate1:30remaining
How does PowerShell pipeline pass data between commands?
In PowerShell, what is passed from one command to the next in a pipeline?
Attempts:
2 left
💡 Hint
PowerShell pipelines are different from traditional text-based shells.
✗ Incorrect
PowerShell pipelines pass objects, not just text, allowing rich data to flow between commands.
📝 Syntax
advanced2:30remaining
Which pipeline syntax correctly filters and selects properties?
Which of the following PowerShell pipelines correctly filters processes with CPU usage over 100 and selects their names?
Attempts:
2 left
💡 Hint
Remember the syntax for script blocks and property access in Where-Object.
✗ Incorrect
Option A uses the correct script block syntax with $_ to access the CPU property and Select-Object to pick the Name property.
🔧 Debug
advanced2:00remaining
Why does this pipeline produce no output?
Given the pipeline below, why does it produce no output?
Get-Service | Where-Object { $_.Status -eq 'Running' } | Where-Object { $_.Name -like 'X*' }
PowerShell
Get-Service | Where-Object { $_.Status -eq 'Running' } | Where-Object { $_.Name -like 'X*' }Attempts:
2 left
💡 Hint
Check the actual service names and their statuses on your system.
✗ Incorrect
The pipeline is correct but likely no running service has a name starting with 'X', so the filter returns no objects.
🚀 Application
expert2:30remaining
How many objects are passed through this pipeline?
How many objects does the pipeline output?
1..10 | ForEach-Object { if ($_ % 3 -eq 0) { $_ } }
PowerShell
1..10 | ForEach-Object { if ($_ % 3 -eq 0) { $_ } }
Attempts:
2 left
💡 Hint
Consider what happens when the if condition is false inside ForEach-Object.
✗ Incorrect
For numbers 1 to 10, the if outputs the number only if divisible by 3 (3,6,9). When the condition is false, the scriptblock produces no output, so only 3 objects are output.