0
0
PowerShellscripting~20 mins

Pipeline concept (|) in PowerShell - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
PowerShell 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 it output?
PowerShell
1..5 | Where-Object { $_ % 2 -eq 0 } | ForEach-Object { $_ * 10 }
A20`n40
B2`n4`n6`n8`n10
C10`n20
D1`n3`n5
Attempts:
2 left
💡 Hint
Think about filtering even numbers first, then multiplying each by 10.
💻 Command Output
intermediate
2:00remaining
What does this pipeline output?
What is the output of this PowerShell command?
PowerShell
'apple','banana','cherry' | Where-Object { $_.Length -gt 5 } | Sort-Object
Acherry`nbanana
Bbanana`ncherry
Capple`nbanana`ncherry
Dapple
Attempts:
2 left
💡 Hint
Filter words longer than 5 letters, then sort alphabetically.
🔧 Debug
advanced
2:00remaining
Why does this pipeline cause an error?
This PowerShell pipeline throws an error. What is the cause?
PowerShell
1..3 | ForEach-Object { $_ / 0 } | Where-Object { $_ -gt 1 }
ADivision by zero error in ForEach-Object block
BWhere-Object cannot process pipeline input
CSyntax error due to missing parentheses
DNo error; outputs 1, 2, 3
Attempts:
2 left
💡 Hint
Check the operation inside ForEach-Object carefully.
🚀 Application
advanced
2:00remaining
Which pipeline command lists files larger than 1MB and sorts by size?
You want to list files in the current folder larger than 1MB, sorted from largest to smallest. Which pipeline command does this?
AGet-ChildItem | Sort-Object Length -Descending | Where-Object { $_.Length -gt 1MB }
BGet-ChildItem | Sort-Object Length | Where-Object { $_.Length -lt 1MB }
CGet-ChildItem | Where-Object { $_.Length -lt 1MB } | Sort-Object Length
DGet-ChildItem | Where-Object { $_.Length -gt 1MB } | Sort-Object Length -Descending
Attempts:
2 left
💡 Hint
Filter first, then sort descending by size.
🧠 Conceptual
expert
2:00remaining
What is the main benefit of using pipelines in PowerShell scripting?
Why do PowerShell users prefer pipelines (|) when writing scripts?
AThey convert all output to plain text for easier reading
BThey automatically parallelize commands to run on multiple CPU cores
CThey allow chaining commands so output of one is input to next, enabling efficient data processing
DThey prevent any errors from stopping the script execution
Attempts:
2 left
💡 Hint
Think about how data flows between commands.