Challenge - 5 Problems
Verbose & Debug Master
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 script with verbose enabled?
Consider this script run with the -Verbose flag:
What will be printed to the console?
function Test-Verbose {
[CmdletBinding()]
param()
Write-Verbose "Starting process"
Write-Output "Process running"
Write-Verbose "Process completed"
}
Test-Verbose -VerboseWhat will be printed to the console?
PowerShell
function Test-Verbose { [CmdletBinding()] param() Write-Verbose "Starting process" Write-Output "Process running" Write-Verbose "Process completed" } Test-Verbose -Verbose
Attempts:
2 left
💡 Hint
Verbose messages appear only when the -Verbose flag is used.
✗ Incorrect
Write-Verbose outputs messages only if the -Verbose flag is specified. Write-Output always prints to the console. So both verbose messages and the output line appear.
💻 Command Output
intermediate2:00remaining
What happens when you use Write-Debug without enabling debug?
Given this script:
What will be the output?
function Test-Debug {
[CmdletBinding()]
param()
Write-Debug "Debug info"
Write-Output "Normal output"
}
Test-DebugWhat will be the output?
PowerShell
function Test-Debug { [CmdletBinding()] param() Write-Debug "Debug info" Write-Output "Normal output" } Test-Debug
Attempts:
2 left
💡 Hint
Debug messages show only when debug preference is enabled.
✗ Incorrect
Write-Debug messages are hidden unless the script is run with -Debug or $DebugPreference is set to 'Continue'. Without that, only Write-Output prints.
📝 Syntax
advanced2:00remaining
Which option correctly enables debug output in a PowerShell script?
You want to see debug messages from Write-Debug in your script. Which code snippet correctly enables debug output?
Attempts:
2 left
💡 Hint
PowerShell uses a preference variable to control debug message display.
✗ Incorrect
Setting $DebugPreference to 'Continue' tells PowerShell to show debug messages. The other options are invalid commands or variables.
🚀 Application
advanced2:00remaining
How to capture verbose output into a variable in PowerShell?
You want to run a command and save its verbose messages into a variable for later use. Which approach works?
Attempts:
2 left
💡 Hint
Verbose messages are sent to stream 4 in PowerShell.
✗ Incorrect
Redirecting stream 4 (verbose) to stream 1 (output) with 4>&1 captures verbose messages into the variable. Option A uses a script block unnecessarily, B captures only output, D redirects the wrong stream.
🧠 Conceptual
expert2:00remaining
What is the effect of setting $VerbosePreference to 'SilentlyContinue'?
In PowerShell, what happens if you set:
and then run a script that uses Write-Verbose?
$VerbosePreference = 'SilentlyContinue'
and then run a script that uses Write-Verbose?
Attempts:
2 left
💡 Hint
The preference variable controls how verbose messages behave.
✗ Incorrect
'SilentlyContinue' means PowerShell ignores verbose messages and does not display them.