CmdID / PowerShell / Cmdlets / Write
Write-Warning
Writes a warning message. PowerShell reference
From the PowerShell reference 1 parameter
What it does
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."IdentifyPass a string to Write-Warning
$w = "This is only a test warning."
$w | Write-WarningIdentifySet 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."IdentifySet 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"):IdentifyIts page in the reference: Write-Warning.
Parameters
-MessageSpecifies the warning message.