Challenge - 5 Problems
PowerShell Pro in VS Code
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this PowerShell command in VS Code terminal?
You run this command in the VS Code integrated terminal with PowerShell extension enabled:
What does this command output?
Get-Process | Where-Object { $_.CPU -gt 100 }What does this command output?
PowerShell
Get-Process | Where-Object { $_.CPU -gt 100 }Attempts:
2 left
💡 Hint
Think about what the 'Where-Object' filter does with the CPU property.
✗ Incorrect
The command lists all processes where the CPU time used is greater than 100 seconds. The 'CPU' property exists on process objects, so no error occurs.
📝 Syntax
intermediate1:30remaining
Which PowerShell script snippet correctly defines a function in VS Code with PowerShell extension?
You want to create a function named 'Get-Greeting' that returns 'Hello World'. Which snippet is correct?
Attempts:
2 left
💡 Hint
PowerShell functions use the keyword 'function' without parentheses for parameters if none.
✗ Incorrect
Option D uses the correct PowerShell syntax for defining a function. Other options use syntax from other languages or invalid keywords.
🔧 Debug
advanced2:00remaining
Why does this PowerShell script fail to run in VS Code with PowerShell extension?
You wrote this script:
When running, you get a syntax error. What is the cause?
Write-Host "Starting script..."
$number = 5
if $number -gt 3
{ Write-Host "Number is greater than 3" }When running, you get a syntax error. What is the cause?
PowerShell
Write-Host "Starting script..." $number = 5 if $number -gt 3 { Write-Host "Number is greater than 3" }
Attempts:
2 left
💡 Hint
PowerShell requires conditions in if statements to be enclosed in parentheses.
✗ Incorrect
PowerShell syntax for if statements requires the condition to be inside parentheses, like: if ($number -gt 3) { ... }
🚀 Application
advanced1:30remaining
How to run a PowerShell script file in VS Code terminal with the PowerShell extension?
You have a script file named 'script.ps1' in your workspace. Which command runs this script correctly in the VS Code integrated terminal?
Attempts:
2 left
💡 Hint
In PowerShell, to run a script in the current directory, you prefix with .\
✗ Incorrect
Option B correctly runs the script by specifying the relative path with .\. Other options are invalid commands.
🧠 Conceptual
expert2:00remaining
What is the purpose of the PowerShell extension in VS Code?
Select the best description of what the PowerShell extension adds to VS Code.
Attempts:
2 left
💡 Hint
Think about what features help you write and debug scripts inside VS Code.
✗ Incorrect
The PowerShell extension enhances VS Code by adding editing features like syntax highlighting, code completion, debugging tools, and terminal integration for PowerShell.