Write-Warning
Additional Resources for Write-Warning |
Writing a Warning Message to the Console Window http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/write-warning.mspx
|
SYNOPSIS
Writes a warning message.
SYNTAX
Write-Warning [-message] <string> [<CommonParameters>]
DETAILED DESCRIPTION
Writes a warning message. The message is sent directly to the host. Whether the message is displayed in the console depends upon the value of the $WarningPreference variable. Type $WarningPreference to see its current value. To set the variable for the session, type $WarningPreference = "<value>". The valid values are: SilentlyContinue, Stop, Continue and Inquire. If the value is SilentlyContinue, Write-Warning does not display a message to the console. When the message is displayed, reverse video is used to highlight it.
PARAMETERS
-message <string>
Specifies the warning message.
Required? |
true |
Position? |
1 |
Default value |
none |
Accept pipeline input? |
true (ByValue) |
Accept wildcard characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. For more information, type, "get-help about_commonparameters".
INPUT TYPE
String
RETURN TYPE
none
NOTES
To determine valid values for a preference variable like $WarningPreference, you can attempt to set it to a string of random characters. The resulting error message will list the valid values.
For more information, type "Get-Help Write-Warning -detailed". For technical information, type "Get-Help Write-Warning -full".
When specifying multiple values for a parameter, use commas to separate the values. For example, "<parameter-name> <value1>, <value2>".
EXAMPLE 1
write-warning "This is only a test warning."
This command displays the message "WARNING: This is only a test warning." unless the value of $WarningPreference is SilentlyContinue.
RELATED LINKS