Write Preferences
suggest changeWrite-Information and $InformationPreference were added in Windows PowerShell 5.0. These commands write messages:
Write-Verbose "Detailed Message"
Write-Information "Information Message"
Write-Debug "Debug Message"
Write-Progress "Progress Message"
Write-Warning "Warning Message"
Each stream has a preference variable. These are the usual defaults:
$VerbosePreference = "SilentlyContinue"
$InformationPreference = "SilentlyContinue"
$DebugPreference = "SilentlyContinue"
$ProgressPreference = "Continue"
$WarningPreference = "Continue"
The preference controls whether the message is shown and whether the script continues:
$InformationPreference = "SilentlyContinue"
Write-Information "This message will not be shown and execution continues"
$InformationPreference = "Continue"
Write-Information "This message is shown and execution continues"
$InformationPreference = "Inquire"
Write-Information "This message is shown and execution will optionally continue"
$InformationPreference = "Stop"
Write-Information "This message is shown and execution terminates"
On the console host, Write-Error colors can be set with:
$host.PrivateData.ErrorBackgroundColor = "Black"
$host.PrivateData.ErrorForegroundColor = "Red"
Similar settings are available for Write-Verbose, Write-Debug and Write-Warning.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents