liveBook · Manning

InformationVariable

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

InformationVariable is a PowerShell common parameter that specifies a variable for capturing information-stream output.

InformationVariable is a PowerShell common parameter that captures Information stream messages in a variable instead of cluttering normal output. Use it with commands that emit Write-Information messages; the alias -IV is available. section 13.4 section 13.4.1

Use the captured records to control visibility and inspect context:

  • Run with -InformationAction Continue to display messages while also capturing them. section 13.4
  • Run with -InformationVariable inf to suppress normal display and collect records in $inf. section 13.4.1
  • Filter captured InformationRecord objects through properties such as Tags and MessageData. section 13.4 section 13.4.1

Capture and filter tagged messages

Example -InformationAction SilentlyContinue -IV x; then use $x | Where-Object Tags -in @('notice') to retain only notice messages. section 13.4

Function Example {
    [CmdletBinding()]
    Param()
    Write-Information "First message" -tag status
    Write-Information "Note that this had no parameters" -tag notice
    Write-Information "Second message" -tag status
}
Example -InformationAction Continue -InformationVariable x

Shows a function emitting tagged messages and a call that displays and captures them. section 13.4

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

How deep it goes
Explains invocation, suppression, aliases, rich records, and tag filtering, but stops short of parameter declaration internals.
Examples
Uses tagged function messages, the -IV alias, InformationRecord members, and filtering records by notice or meta tags.
What it assumes
Assumes familiarity with PowerShell commands and variables while demonstrating Write-Information, tags, and common parameter behavior.
What you can do after
Apply it via PowerShell to capture, inspect, and filter informational messages without mixing them into normal output.
How it connects
Connects InformationVariable with the Information stream, Write-Information, Write-Host, InformationAction, and message tags.

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.