Bird
0
0

You wrote a script using Write-Debug messages, but no debug output appears when running it with -Debug. What is the most likely cause?

medium📝 Debug Q14 of 15
PowerShell - Scripting Best Practices
You wrote a script using Write-Debug messages, but no debug output appears when running it with -Debug. What is the most likely cause?
AThe debug preference variable <code>$DebugPreference</code> is set to 'SilentlyContinue'
BThe script does not contain any <code>Write-Debug</code> commands
CThe script was run with <code>-Verbose</code> instead of <code>-Debug</code>
DThe script has syntax errors preventing debug output
Step-by-Step Solution
Solution:
  1. Step 1: Check $DebugPreference effect

    Even with -Debug, if $DebugPreference is 'SilentlyContinue', debug messages won't show.
  2. Step 2: Verify other options

    The script does not contain any Write-Debug commands means no debug commands, but question states debug commands exist. The script was run with -Verbose instead of -Debug is about verbose, not debug. The script has syntax errors preventing debug output would cause errors, not silent debug.
  3. Final Answer:

    The debug preference variable $DebugPreference is set to 'SilentlyContinue' -> Option A
  4. Quick Check:

    $DebugPreference controls debug output display [OK]
Quick Trick: Check $DebugPreference; must not be 'SilentlyContinue' to see debug [OK]
Common Mistakes:
  • Confusing -Verbose with -Debug flags
  • Ignoring $DebugPreference variable
  • Assuming debug always shows if -Debug used

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes