0
0
PowerShellscripting~20 mins

PowerShell vs Bash vs CMD comparison - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Shell Scripting Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
PowerShell vs Bash: Command Output Differences
What is the output of this PowerShell command compared to its Bash equivalent?

PowerShell: Get-ChildItem | Where-Object { $_.Length -gt 1000 }
Bash: ls -l | awk '$5 > 1000'

Assuming both commands run in a directory with files of various sizes, what does the PowerShell command output?
PowerShell
Get-ChildItem | Where-Object { $_.Length -gt 1000 }
ALists only directories larger than 1000 bytes
BLists all files and directories regardless of size
CLists files with size greater than 1000 bytes, including directories with Length property
DLists files with size less than 1000 bytes
Attempts:
2 left
💡 Hint
Think about how PowerShell objects have properties like Length and how Where-Object filters them.
📝 Syntax
intermediate
1:30remaining
Syntax Differences: Variable Assignment
Which of the following is the correct way to assign a variable in PowerShell compared to Bash and CMD?
A$var = "Hello"
Bvar = "Hello"
Cset var=Hello
Dlet var = "Hello"
Attempts:
2 left
💡 Hint
PowerShell uses $ before variable names.
🔧 Debug
advanced
2:00remaining
Debugging a PowerShell Pipeline vs Bash Pipeline
Given this PowerShell pipeline:
Get-Process | Where-Object { $_.CPU -gt 100 }
and this Bash pipeline:
ps aux | awk '$3 > 100'
Which statement about their behavior is true?
ABoth commands will produce syntax errors
BPowerShell filters processes with CPU time greater than 100 seconds; Bash filters processes with CPU usage percentage greater than 100%
CPowerShell filters processes with CPU usage percentage over 100%; Bash filters CPU time over 100 seconds
DBoth filter processes with CPU usage over 100%
Attempts:
2 left
💡 Hint
Consider what the CPU property in PowerShell and the third column in ps aux represent.
🚀 Application
advanced
2:30remaining
Automating File Backup: PowerShell vs CMD
You want to copy all .txt files from C:\Data to D:\Backup preserving directory structure.
Which PowerShell command correctly does this compared to CMD's xcopy C:\Data D:\Backup /S /I /Y?
ACopy-Item -Path C:\Data\*.txt -Destination D:\Backup -Recurse -Container
BCopy-Item -Path C:\Data\*.txt -Destination D:\Backup -Recurse -Force
CCopy-Item -Path C:\Data\*.txt -Destination D:\Backup -Recurse
DCopy-Item -Path C:\Data\*.txt -Destination D:\Backup -Force
Attempts:
2 left
💡 Hint
Preserving directory structure requires the -Container parameter in PowerShell.
🧠 Conceptual
expert
3:00remaining
Understanding Object vs Text Pipelines
PowerShell pipelines pass objects between commands, while Bash and CMD pipelines pass text streams.
What is a key advantage of PowerShell's object pipeline over text pipelines?
AIt only works on Windows, so it is more secure
BIt makes scripts run faster because objects are smaller than text
CIt requires less memory because objects are compressed
DIt allows commands to access properties and methods directly, enabling more precise and reliable automation
Attempts:
2 left
💡 Hint
Think about how objects carry structured data compared to plain text.