CmdID

CmdID / PowerShell / Cmdlets / Write

Write-Warning

Writes a warning message. PowerShell reference

From the PowerShell reference 1 parameter

Opens CmdID with your command, read as PowerShell. It is read in your browser and sent nowhere.

What it does

from the PowerShell reference, CC BY 4.0

Writes a warning message. The Write-Warning cmdlet writes a warning message to the PowerShell host. The response to the warning depends on the value of the user's $WarningPreference variable and the use of the WarningAction common parameter.

Write-Warning [-Message] <String> [<CommonParameters>]

Write a warning message

Write-Warning "This is only a test warning."Identify

Pass a string to Write-Warning

$w = "This is only a test warning." $w | Write-WarningIdentify

Set the $WarningPreference variable and write a warning

PS> $WarningPreference Continue PS> Write-Warning "This is only a test warning." This is only a test warning. PS> $WarningPreference = "SilentlyContinue" PS> Write-Warning "This is only a test warning." PS> $WarningPreference = "Stop" PS> Write-Warning "This is only a test warning." WARNING: This is only a test warning. Write-Warning : Command execution stopped because the shell variable "WarningPreference" is set to Stop. At line:1 char:14 + Write-Warning <<<< "This is only a test warning."Identify

Set the WarningAction parameter and write a warning

PS> Write-Warning "This is only a test warning." -WarningAction Inquire WARNING: This is only a test warning. Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"):Identify

Its page in the reference: Write-Warning.

Parameters

1 in the PowerShell reference
-MessageSpecifies the warning message.