Skip to main content
Cmdlet.WriteWarning Method
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Writes a warning message that can be displayed.


Namespace: System.Management.Automation
Assembly: System.Management.Automation (in System.Management.Automation.dll)
Usage
Dim instance As Cmdlet
Dim text As String

instance.WriteWarning(text)
Syntax
Public Sub WriteWarning ( _
	text As String _
)
public void WriteWarning (
	string text
)
public:
void WriteWarning (
	String^ text
)
public void WriteWarning (
	String text
)
public function WriteWarning (
	text : String
)

Parameters

text

The warning message to be displayed.

Exceptions
Exception typeCondition
PipelineStoppedException

The pipeline is stopped. The pipeline was terminated either before the call was made or while the call was in progress. By default, the cmdlet should allow the caller of the processing record method to catch this exception.

InvalidOperationException

The call cannot be completed at this time or cannot be completed from this thread. For more information, see the following Remarks section.

Remarks

Use the WriteWarning method to display warnings about the activity of your cmdlet. By default, warning output is discarded, although this can be configured with the WarningPreference shell variable or with the -Verbose and -Debug command-line options.

This method can be called only from within the cmdlet implementation of the BeginProcessing, ProcessRecord, and EndProcessing methods and only from that thread. If the call is made outside one of these implementations or from another thread, an InvalidOperationException exception is thrown.

Cmdlets that are in invoked from within a cmdlet (the invoked cmdlet must derive directly from the Cmdlet class) can implement the ICommandRuntime interface which can be used to override the default behavior of this method.


Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

 

Target Platforms

Windows Developer Preview, Windows Server Developer Preview

Send comments about this topic to Microsoft.