Bird
Raised Fist0
PowerShellscripting~20 mins

Why PowerShell exists - Challenge Your Understanding

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
PowerShell Automation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Purpose of PowerShell
Why was PowerShell created as a scripting and automation tool?
ATo replace all graphical user interfaces with text-based commands only.
BTo act as a web development framework for creating websites.
CTo serve as a programming language for building mobile applications.
DTo provide a command-line shell and scripting language that integrates with Windows and supports automation of system tasks.
Attempts:
2 left
💡 Hint
Think about what tasks system administrators need to automate on Windows.
🧠 Conceptual
intermediate
2:00remaining
PowerShell vs Traditional Shells
What is a key reason PowerShell was developed instead of just using traditional shells like CMD or Bash?
APowerShell was created to only run on Linux systems.
BPowerShell is designed only for web developers.
CPowerShell uses objects instead of plain text, making it easier to manipulate complex data.
DPowerShell removes the need for any scripting by automating everything automatically.
Attempts:
2 left
💡 Hint
Think about how data is passed between commands in PowerShell compared to older shells.
💻 Command Output
advanced
2:00remaining
PowerShell Command Output Format
What is the output of this PowerShell command? Get-Process | Select-Object -First 1 | Get-Member -MemberType Property | Select-Object -First 3 -ExpandProperty Name
PowerShell
Get-Process | Select-Object -First 1 | Get-Member -MemberType Property | Select-Object -First 3 -ExpandProperty Name
A
BasePriority
EnableRaisingEvents
ExitCode
B
ProcessName
Id
CPU
C
Name
Id
Handles
D
Id
CPU
ProcessName
Attempts:
2 left
💡 Hint
Get-Member lists properties alphabetically by default.
🔧 Debug
advanced
2:00remaining
Identify the Error in PowerShell Script
What error will this PowerShell script produce? $services = Get-Service | Where-Object Status -eq 'Running' $services | ForEach-Object { $_.Name }
PowerShell
$services = Get-Service | Where-Object Status -eq 'Running'
$services | ForEach-Object { $_.Name }
ARuntimeError: Property 'Name' does not exist
BSyntaxError: Missing script block for Where-Object
CNo error; outputs names of running services
DTypeError: Cannot pipe objects to ForEach-Object
Attempts:
2 left
💡 Hint
Check the syntax of the Where-Object command.
🚀 Application
expert
3:00remaining
Automating File Backup with PowerShell
Which PowerShell script correctly copies all .txt files from C:\Data to D:\Backup, creating the destination folder if it doesn't exist?
Aif (-not (Test-Path 'D:\Backup')) { New-Item -ItemType Directory -Path 'D:\Backup' } Copy-Item -Path 'C:\Data\*.txt' -Destination 'D:\Backup'
BCopy-Item -Path 'C:\Data\*.txt' -Destination 'D:\Backup' -Force -Recurse
CNew-Item -ItemType Directory -Path 'D:\Backup' Copy-Item 'C:\Data\*.txt' 'D:\Backup'
DCopy-Item -Path 'C:\Data\*.txt' -Destination 'D:\Backup' -Recurse
Attempts:
2 left
💡 Hint
Check if the destination folder exists before copying files.

Practice

(1/5)
1. Why was PowerShell created?
Choose the main reason.
easy
A. To help automate and simplify managing computers
B. To replace all programming languages
C. To create video games
D. To design websites

Solution

  1. Step 1: Understand PowerShell's purpose

    PowerShell was designed to make managing computers easier by automating tasks.
  2. Step 2: Eliminate unrelated options

    Creating video games, designing websites, or replacing all programming languages are not PowerShell's goals.
  3. Final Answer:

    To help automate and simplify managing computers -> Option A
  4. Quick Check:

    PowerShell exists to automate management = D [OK]
Hint: PowerShell is about automation and management [OK]
Common Mistakes:
  • Thinking PowerShell is for web design
  • Confusing PowerShell with programming languages
  • Assuming it is for game development
2. Which of these is the correct way to run a simple PowerShell command to list files?
Choose the correct syntax.
easy
A. list_files()
B. Get-ChildItem
C. ls -l
D. dir_files

Solution

  1. Step 1: Identify PowerShell cmdlet syntax

    PowerShell uses cmdlets like Get-ChildItem to list files.
  2. Step 2: Compare options

    list_files() and dir_files are not PowerShell commands; ls -l is a Linux command.
  3. Final Answer:

    Get-ChildItem -> Option B
  4. Quick Check:

    PowerShell file list command = A [OK]
Hint: PowerShell commands use Verb-Noun format [OK]
Common Mistakes:
  • Using Linux commands like ls -l in PowerShell
  • Trying to call functions like list_files() without definition
  • Assuming dir_files is a valid command
3. What will this PowerShell command output?
Get-Process | Where-Object { $_.CPU -gt 100 }
medium
A. Processes using more than 100 CPU seconds
B. All processes running on the system
C. Processes with CPU usage less than 100
D. An error because of wrong syntax

Solution

  1. Step 1: Understand the command parts

    Get-Process lists all processes; Where-Object filters those with CPU > 100 seconds.
  2. Step 2: Interpret the filter condition

    The condition $_.CPU -gt 100 means CPU time greater than 100 seconds.
  3. Final Answer:

    Processes using more than 100 CPU seconds -> Option A
  4. Quick Check:

    Filter processes by CPU > 100 = C [OK]
Hint: Where-Object filters output by condition [OK]
Common Mistakes:
  • Thinking it lists all processes without filtering
  • Confusing CPU time with CPU percentage
  • Assuming syntax error due to $_ usage
4. This PowerShell script has an error:
Get-Service | Where-Object { $_.Status = 'Running' }

What is the error?
medium
A. Where-Object cannot filter by Status
B. Missing a closing brace '}'
C. Get-Service is not a valid command
D. Using '=' instead of '-eq' for comparison

Solution

  1. Step 1: Identify the comparison operator

    The script uses '=' which assigns value instead of comparing.
  2. Step 2: Correct operator for comparison in PowerShell

    PowerShell uses '-eq' to test equality, so '=' should be '-eq'.
  3. Final Answer:

    Using '=' instead of '-eq' for comparison -> Option D
  4. Quick Check:

    Comparison needs '-eq' not '=' = A [OK]
Hint: Use '-eq' for equality, not '=' [OK]
Common Mistakes:
  • Using '=' instead of '-eq' for comparisons
  • Thinking Get-Service is invalid
  • Assuming missing brace error
5. You want to automate checking if a service named 'Spooler' is running and start it if not. Which script correctly does this?
hard
A. Start-Service -Name 'Spooler' if (Get-Service 'Spooler').Status = 'Stopped'
B. Get-Service 'Spooler' | Start-Service if Status -eq 'Stopped'
C. if ((Get-Service -Name 'Spooler').Status -ne 'Running') { Start-Service -Name 'Spooler' }
D. if (Get-Service 'Spooler').Status = 'Running' { Stop-Service 'Spooler' }

Solution

  1. Step 1: Check service status correctly

    Use Get-Service with -Name and check if Status is not 'Running' using -ne.
  2. Step 2: Start service if not running

    If service is not running, call Start-Service with the same name.
  3. Final Answer:

    if ((Get-Service -Name 'Spooler').Status -ne 'Running') { Start-Service -Name 'Spooler' } -> Option C
  4. Quick Check:

    Check status then start if stopped = B [OK]
Hint: Use if with -ne and Start-Service [OK]
Common Mistakes:
  • Using '=' instead of '-eq' or '-ne' in conditions
  • Placing Start-Service before condition
  • Stopping service instead of starting
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard