Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the purpose of verbose output in PowerShell scripts?
Verbose output provides extra details about what a script is doing. It helps you understand the steps the script takes without changing the main output.
Click to reveal answer
beginner
How do you enable verbose messages when running a PowerShell script?
Use the -Verbose switch when running the script or command. For example: .\script.ps1 -Verbose.
Click to reveal answer
intermediate
What is the difference between verbose output and debug output in PowerShell?
Verbose output shows extra information about normal script steps. Debug output shows detailed info mainly for troubleshooting and is usually more technical.
Click to reveal answer
beginner
How do you write a debug message inside a PowerShell script?
Use the <code>Write-Debug</code> cmdlet followed by your message. For example: <code>Write-Debug "This is a debug message"</code>.
Click to reveal answer
beginner
How can you enable debug messages when running a PowerShell script?
Use the -Debug switch when running the script or command. For example: .\script.ps1 -Debug.
Click to reveal answer
Which switch shows verbose messages when running a PowerShell script?
A-Debug
B-Verbose
C-Trace
D-Info
✗ Incorrect
The -Verbose switch enables verbose output, showing extra details about script execution.
What cmdlet do you use to write a debug message inside a PowerShell script?
AWrite-Verbose
BWrite-Output
CWrite-Debug
DWrite-Error
✗ Incorrect
Write-Debug writes debug messages that appear only when debug mode is enabled.
If you want to see debug messages, which switch should you add when running a script?
A-Debug
B-ShowDebug
C-Verbose
D-Trace
✗ Incorrect
The -Debug switch enables debug messages during script execution.
Verbose output is best described as:
AExtra details about script steps
BFinal script output
CUser input prompts
DError messages only
✗ Incorrect
Verbose output provides extra information about what the script is doing step-by-step.
Which cmdlet would NOT show output unless its switch is enabled?
AWrite-Error
BWrite-Output
CWrite-Host
DWrite-Verbose
✗ Incorrect
Write-Verbose messages appear only if the -Verbose switch is used.
Explain how to add verbose and debug messages in a PowerShell script and how to enable them when running the script.
Think about the cmdlets and switches that control extra output.
You got /4 concepts.
Describe the difference between verbose output and debug output in PowerShell and when you might use each.
Consider the purpose and detail level of each output type.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of using Write-Verbose in a PowerShell script?
easy
A. To stop the script execution immediately
B. To write error messages to the console
C. To show extra informational messages when the script runs with -Verbose enabled
D. To create output files automatically
Solution
Step 1: Understand Write-Verbose purpose
Write-Verbose is used to add extra informational messages that only show when the script is run with the -Verbose flag.
Step 2: Differentiate from other commands
It does not stop execution, write errors, or create files. It only provides optional extra info.
Final Answer:
To show extra informational messages when the script runs with -Verbose enabled -> Option C
Quick Check:
Verbose messages = extra info shown with -Verbose [OK]
Hint: Verbose shows extra info only when -Verbose is used [OK]
Common Mistakes:
Confusing Write-Verbose with Write-Error
Expecting verbose messages without -Verbose flag
Thinking Write-Verbose stops script execution
2. Which of the following is the correct syntax to enable debug messages in a PowerShell script?
easy
A. Run the script with -Debug parameter
B. Add Write-Debug -Enable inside the script
C. Use Set-DebugMode On before running the script
D. Include Enable-Debug command in the script
Solution
Step 1: Identify how to enable debug output
Debug messages appear when the script is run with the -Debug parameter.
Step 2: Check other options for validity
There is no Write-Debug -Enable, Set-DebugMode, or Enable-Debug commands in PowerShell.
Final Answer:
Run the script with -Debug parameter -> Option A
Quick Check:
Debug enabled by running script with -Debug [OK]
Hint: Use -Debug flag when running script to see debug messages [OK]
Common Mistakes:
Trying to enable debug inside script with wrong commands
Confusing debug enabling with verbose enabling
Assuming debug is always on by default
3. What will be the output when running this script with -Verbose?
C. Process running\nStarting process\nProcess completed
D. Starting process\nProcess running\nProcess completed
Solution
Step 1: Understand Write-Verbose output with -Verbose
When run with -Verbose, all Write-Verbose messages show along with normal output.
Step 2: Identify output order
The script writes verbose messages "Starting process" and "Process completed" plus the normal output "Process running" in order.
Final Answer:
Starting process
Process running
Process completed -> Option D
Quick Check:
Verbose + Output = all messages shown [OK]
Hint: Verbose messages show only with -Verbose, normal output always shows [OK]
Common Mistakes:
Ignoring verbose messages in output
Assuming verbose messages appear without -Verbose
Mixing order of output lines
4. 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
A. The debug preference variable $DebugPreference is set to 'SilentlyContinue'
B. The script does not contain any Write-Debug commands
C. The script was run with -Verbose instead of -Debug
D. The script has syntax errors preventing debug output
Solution
Step 1: Check $DebugPreference effect
Even with -Debug, if $DebugPreference is 'SilentlyContinue', debug messages won't show.
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.
Final Answer:
The debug preference variable $DebugPreference is set to 'SilentlyContinue' -> Option A
Hint: 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
5. You want to write a PowerShell script that shows detailed debug messages only when debugging is enabled, and verbose messages only when verbose is enabled. Which code snippet correctly implements this behavior?