0
0
PowerShellscripting~20 mins

Pipeline object flow in PowerShell - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pipeline Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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 }
A2 4 6 8 10
B3 6 9 12 15
C6 12
D3 9 15
Attempts:
2 left
💡 Hint
Think about which numbers pass the filter and what happens next.
🧠 Conceptual
intermediate
1:30remaining
How does PowerShell pipeline pass data between commands?
In PowerShell, what is passed from one command to the next in a pipeline?
AText strings representing command output
BRaw bytes of command output
CFile paths of output files
DObjects representing data
Attempts:
2 left
💡 Hint
PowerShell pipelines are different from traditional text-based shells.
📝 Syntax
advanced
2: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?
AGet-Process | Where-Object { $_.CPU -gt 100 } | Select-Object Name
BGet-Process | Where-Object CPU -gt 100 | Select-Object Name
CGet-Process | Where-Object { CPU > 100 } | Select-Object Name
DGet-Process | Where-Object { $_.CPU > 100 } | Select Name
Attempts:
2 left
💡 Hint
Remember the syntax for script blocks and property access in Where-Object.
🔧 Debug
advanced
2: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*' }
ANo services have names starting with 'X' while running
BThe -like operator is case-sensitive and fails
CThe pipeline syntax is invalid and causes an error
DGet-Service does not output objects with Status property
Attempts:
2 left
💡 Hint
Check the actual service names and their statuses on your system.
🚀 Application
expert
2: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) { $_ } }
A10
B3
C0
D7
Attempts:
2 left
💡 Hint
Consider what happens when the if condition is false inside ForEach-Object.