PowerShell Genie

Write-Verbose

Use Write-Verbose to write a diagnostic message that stays hidden unless the caller asks for it with -Verbose.

Command 1 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Write-Verbose

Syntax

1PS> Write-Verbose [-Message] <String> [<CommonParameters>]
See the command anatomy

Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

Write-Verbose [-Message] <String> [<CommonParameters>]
  1. Stage 1Write-Verbose-Message

    Try it

    Windows PowerShell

    PowerShell example · browser support is limited.

    Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

    Interactive simulation · fictional data

    Examples

    Write-Verbose -Verbose

    1PS> Write-Verbose 'Connecting to WEB01' -Verbose
    Show reference output

    Sample output · fictional data, shaped like the real thing

    VERBOSE: Connecting to WEB01

    Write-Verbose -Verbose (2)

    1PS> function Test-Thing {
    2PS> [CmdletBinding()]
    3PS> param()
    4PS> Write-Verbose 'checking'
    5PS> 'done'
    6PS> }
    7PS> Test-Thing -Verbose
    Show reference output

    Sample output · fictional data, shaped like the real thing

    VERBOSE: checking

    Write-Verbose -Verbose (3)

    1PS> Write-Verbose "Retry count is 3" -Verbose
    Show reference output

    Sample output · fictional data, shaped like the real thing

    VERBOSE: Retry count is 3

    Parameters

    Parameter definitions:

    • -Message

    Write-Verbose on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Write-Verbose when you need to write a diagnostic message that stays hidden unless the caller asks for it with -Verbose. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.

    Common error and fix: No visible message often means verbose output is disabled. Invoke the advanced command with -Verbose or configure VerbosePreference deliberately; keep credentials out of diagnostic text. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.

    See also: Write-Debug. Write-Verbose provides optional operational detail; Write-Debug provides debugging detail. Their visibility is controlled separately and neither should be used as ordinary function return data. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Write-Verbose reference on Microsoft Learn

    Recap

    Write-Verbose Use Write-Verbose to write a diagnostic message that stays hidden unless the caller asks for it with -Verbose.

    Next: Write-Debug
    Genie guideWrite-Verbose

    Use Write-Verbose to write a diagnostic message that stays hidden unless the caller asks for it with -Verbose. The console below is pre-loaded — run it, then change a value and run it again.