0
0
PowerShellscripting~20 mins

Why PowerShell is object-oriented - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
PowerShell Object Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output type of this PowerShell command?
Consider the following PowerShell command:
Get-Process | Select-Object -First 1

What type of object does this command output?
PowerShell
Get-Process | Select-Object -First 1 | Get-Member -MemberType Property
AA string representing the process name
BA plain text table with no object properties
CA numeric value representing process ID
DAn object with properties describing the process
Attempts:
2 left
💡 Hint
Think about what Get-Process returns and how PowerShell treats output.
🧠 Conceptual
intermediate
1:30remaining
Why does PowerShell treat output as objects?
Why does PowerShell output objects instead of plain text like many other shells?
ABecause objects allow easy access to properties and methods for automation
BBecause text output is slower to display on screen
CBecause PowerShell cannot handle text output
DBecause objects use less memory than text
Attempts:
2 left
💡 Hint
Think about how automation scripts benefit from structured data.
🔧 Debug
advanced
2:00remaining
Identify the error in this PowerShell pipeline
What error occurs when running this command?
Get-Process | Where-Object { $_.Name -eq 'notepad' } | Select-Object CPU
PowerShell
Get-Process | Where-Object { $_.Name -eq 'notepad' } | Select-Object CPU
ANo error; outputs CPU property of notepad processes
BSyntax error due to missing parentheses
CError: Property 'CPU' does not exist on some objects
DRuntime error because 'notepad' process does not exist
Attempts:
2 left
💡 Hint
Check if the CPU property exists on process objects.
🚀 Application
advanced
2:00remaining
Extracting object properties in PowerShell
You want to list the names and IDs of all running processes. Which command produces the correct output?
AGet-Process | Format-Table Name, Id
BGet-Process | Select-Object Name, Id
CGet-Process | Where-Object { Name, Id }
DGet-Process | ForEach-Object { $_.Name + $_.Id }
Attempts:
2 left
💡 Hint
Select-Object extracts properties as objects; Format-Table formats output but does not produce objects.
📝 Syntax
expert
2:30remaining
What is the output of this PowerShell object method call?
Given this code:
$proc = Get-Process -Id $PID
$proc.ToString()

What is the output?
AThe process ID number as a string
BThe string 'System.Diagnostics.Process'
CThe process name of the current PowerShell session
DAn error because ToString() is not a method
Attempts:
2 left
💡 Hint
Process class overrides ToString() to return the ProcessName property.