liveBook · Manning

Write-Information

As explained in Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools

Write-Information is a PowerShell cmdlet that writes messages to the information stream.

Write-Information sends structured messages to PowerShell’s Information stream. The stream is suppressed by default through $InformationPreference = SilentlyContinue, so use -InformationAction Continue when messages should appear. section 13.4

Use the cmdlet deliberately when automation needs informational output that can be displayed, captured, or filtered.

  • Pass the message as the first argument through -MessageData, then add tags such as Process, Meta, or Data. section 13.4
  • Enable display with -InformationAction Continue, or suppress display while collecting records with -InformationVariable. section 13.4
  • Treat captured values as InformationRecord objects whose MessageData, Tags, source, time, and process properties can be inspected. section 13.4.1
  • Prefer Write-Information over Write-Host when the output belongs in the Information stream; use Write-Progress for ongoing process feedback. section 18.9

Tagged messages with separate display and capture

A function can emit tagged messages such as “First message” with the status tag and “Note that this had no parameters” with the notice tag. Run it with -InformationAction SilentlyContinue -InformationVariable x to keep the console quiet, then filter $x for records whose Tags include notice.

How Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools covers it

How deep it goes
Explains preferences, common parameters, tags, captured records, and Write-Host tradeoffs, but stops short of stream internals.
Examples
Demonstrates tagged status messages, quiet capture into a variable, InformationRecord inspection, and process-reporting functions.
What it assumes
Assumes PowerShell functions and common parameters, while demonstrating stream preferences and structured message capture.
What you can do after
Apply it to build functions whose informational output can be enabled interactively or captured for later analysis.
How it connects
Links informational output with PowerShell streams, common parameters, Write-Verbose, Write-Host, Write-Progress, and structured records.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools. The section links point to the parts of the book it draws on.