PowerShell Genie

Write-Information

Use Write-Information to write a tagged message to the information stream, which can be captured separately from output.

Command 1 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Write-Information

Syntax

1PS> Write-Information [-MessageData] <Object> [[-Tags] <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-Information [-MessageData] <Object> [[-Tags] <string[]>] [<CommonParameters>]
  1. Stage 1Write-Information-MessageData -Tags

    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-Information -InformationAction Continue

    1PS> Write-Information 'Starting run' -InformationAction Continue
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Starting run

    Write-Information -Tags 'progress'

    1PS> Write-Information 'Batch 1 done' -Tags 'progress' -InformationAction Continue
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Batch 1 done

    Write-Information -InformationAction Continue (2)

    1PS> Write-Information ([pscustomobject]@{ Stage = 'import';Rows = 412 }) -InformationAction Continue
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Stage    Rows
    -----    ----
    Collect  42

    Parameters

    Parameter definitions:

    • -MessageData
    • -Tags

    Write-Information on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Write-Information when you need to write a tagged message to the information stream, which can be captured separately from output. 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: A missing information message may reflect InformationPreference. Use -InformationAction Continue when displaying it is intended, rather than moving the message into the success stream. 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-Output. Write-Output sends values to the success stream; Write-Information sends an informational message to a separate stream. Function return data should not be mixed with progress narration. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Write-Information reference on Microsoft Learn

    Recap

    Write-Information Use Write-Information to write a tagged message to the information stream, which can be captured separately from output.

    Next: Write-Output
    Genie guideWrite-Information

    Use Write-Information to write a tagged message to the information stream, which can be captured separately from output. The console below is pre-loaded — run it, then change a value and run it again.