Bird
0
0

Given this advanced function, what will be the output when called as Get-Info -Verbose?

medium📝 Command Output Q5 of 15
PowerShell - Functions
Given this advanced function, what will be the output when called as Get-Info -Verbose?
function Get-Info {
  [CmdletBinding()]
  param()
  Write-Verbose "Starting function"
  Write-Output "Info retrieved"
}
AError: Verbose not supported
BStarting function Info retrieved
CInfo retrieved
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Understand Write-Verbose behavior

    Write-Verbose outputs messages only if -Verbose is enabled and the host supports it. The function has CmdletBinding, so -Verbose is supported.
  2. Step 2: Check output when called with -Verbose

    Calling with -Verbose enables verbose messages, but Write-Verbose output goes to verbose stream, not standard output. Write-Output outputs "Info retrieved" to standard output.
  3. Final Answer:

    Info retrieved -> Option C
  4. Quick Check:

    Verbose messages do not appear in standard output [OK]
Quick Trick: Write-Verbose outputs to verbose stream, not standard output [OK]
Common Mistakes:
  • Expecting Write-Verbose output in standard output
  • Assuming verbose messages print without -Verbose
  • Confusing Write-Verbose with Write-Output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes