PowerShell is a task automation and configuration management framework from Microsoft, mainly used for managing Windows systems but also supports Linux and macOS.
Click to reveal answer
beginner
How does Bash differ from CMD in terms of platform support?
Bash is mainly used on Unix-like systems such as Linux and macOS, while CMD is a Windows-only command-line interpreter.
Click to reveal answer
intermediate
Which shell supports object-based output instead of plain text?
PowerShell outputs objects, allowing more complex data manipulation, unlike Bash and CMD which output plain text.
Click to reveal answer
beginner
What is a common scripting language used in Bash?
Bash scripts use shell scripting language, which includes commands, loops, and conditionals designed for Unix-like systems.
Click to reveal answer
intermediate
Why might someone choose PowerShell over CMD?
PowerShell offers advanced scripting capabilities, access to .NET libraries, and object-based output, making it more powerful and flexible than CMD.
Click to reveal answer
Which shell is native to Windows and supports object-based output?
ABash
BCMD
CPowerShell
DZsh
✗ Incorrect
PowerShell is native to Windows and outputs objects, unlike CMD which outputs text.
Which shell is primarily used on Unix-like systems?
ABash
BPowerShell
CCMD
DPowerShell Core
✗ Incorrect
Bash is the default shell on most Unix-like systems such as Linux and macOS.
Which shell is considered the most basic and limited in scripting on Windows?
ACMD
BFish
CBash
DPowerShell
✗ Incorrect
CMD is the traditional Windows command prompt with limited scripting compared to PowerShell.
Which shell allows direct access to .NET libraries?
AZsh
BCMD
CBash
DPowerShell
✗ Incorrect
PowerShell can access .NET libraries, enabling powerful scripting and automation.
Which shell outputs plain text instead of objects?
APowerShell
BBash and CMD
CBash
DCMD
✗ Incorrect
Both Bash and CMD output plain text, unlike PowerShell which outputs objects.
Explain the main differences between PowerShell, Bash, and CMD in terms of platform support and output type.
Think about where each shell runs and how they handle command output.
You got /5 concepts.
Describe why PowerShell might be preferred over CMD for scripting on Windows.
Consider scripting power and integration capabilities.
You got /4 concepts.
Practice
(1/5)
1. Which shell is object-based and primarily designed for Windows automation?
easy
A. CMD
B. Bash
C. PowerShell
D. Zsh
Solution
Step 1: Understand shell types
PowerShell is known for handling objects, unlike Bash and CMD which handle text.
Step 2: Identify platform focus
PowerShell is designed mainly for Windows automation, while Bash is common on Linux/macOS and CMD is basic Windows shell.
Final Answer:
PowerShell -> Option C
Quick Check:
Object-based Windows shell = PowerShell [OK]
Hint: PowerShell = objects + Windows automation [OK]
Common Mistakes:
Confusing Bash as object-based
Thinking CMD is object-based
Selecting shells not related to Windows
2. Which of the following is the correct way to list files in PowerShell?
easy
A. ls -l
B. listfiles
C. dir /w
D. Get-ChildItem
Solution
Step 1: Recall PowerShell commands
PowerShell uses cmdlets like Get-ChildItem to list files.
Step 2: Compare with other shells
ls -l is Bash/Linux syntax, dir /w is CMD syntax, listfiles is invalid.
Final Answer:
Get-ChildItem -> Option D
Quick Check:
PowerShell file list = Get-ChildItem [OK]
Hint: PowerShell cmdlets start with Get- or Set- [OK]
Common Mistakes:
Using Bash command ls -l in PowerShell
Using CMD dir /w in PowerShell
Typing invalid commands like listfiles
3. What will be the output of this PowerShell command?
Get-Process | Where-Object { $_.CPU -gt 100 }
medium
A. Lists all processes with CPU usage less than 100 seconds
B. Lists all processes with CPU usage greater than 100 seconds
C. Shows an error because CPU property does not exist
D. Lists all processes regardless of CPU usage
Solution
Step 1: Understand Get-Process output
Get-Process returns process objects with a CPU property showing CPU time in seconds.
Step 2: Analyze Where-Object filter
The filter $_.CPU -gt 100 selects processes with CPU time greater than 100 seconds.
Final Answer:
Lists all processes with CPU usage greater than 100 seconds -> Option B
Quick Check:
Filter CPU > 100 seconds = Lists all processes with CPU usage greater than 100 seconds [OK]
Hint: Where-Object filters objects by property conditions [OK]
Common Mistakes:
Confusing greater than (gt) with less than
Assuming CPU property is missing
Thinking it lists all processes without filtering
4. Identify the error in this PowerShell command that tries to list files:
ls -l | grep ".txt"
medium
A. PowerShell does not support ls -l syntax
B. grep is not a native PowerShell command
C. Quotes around .txt should be single quotes
D. The pipe symbol | is invalid in PowerShell
Solution
Step 1: Check command compatibility
PowerShell supports ls alias but not with -l option; it uses Get-ChildItem instead.
Step 2: Identify grep usage
grep is a Linux command, not native in PowerShell; PowerShell uses Where-Object or Select-String.
Final Answer:
PowerShell does not support ls -l syntax -> Option A
Quick Check:
ls -l syntax unsupported = PowerShell does not support ls -l syntax [OK]
Hint: PowerShell ls alias lacks Bash -l flag [OK]
Common Mistakes:
Assuming ls -l works fully in PowerShell
Thinking pipe | is invalid
Believing quote style causes error here
5. You want to write a script that works on Windows and Linux to list files. Which approach is best?
hard
A. Write a PowerShell script using Get-ChildItem and run PowerShell Core on both OS
B. Write a Bash script using ls and run it only on Linux
C. Write a CMD batch file using dir and run it on Windows only
D. Write separate scripts for each OS and manually switch
Solution
Step 1: Consider cross-platform support
PowerShell Core (PowerShell 7+) runs on Windows and Linux, supporting Get-ChildItem on both.
Step 2: Evaluate other options
Bash scripts work only on Linux/macOS; CMD batch files only on Windows; separate scripts add complexity.
Final Answer:
Write a PowerShell script using Get-ChildItem and run PowerShell Core on both OS -> Option A