CmdletProvider.ShouldProcess Method (String, String, String)

Confirms the operation with the user. This variant of the overloaded method sends a description of the action to be taken, a query asking if the action should be taken, and a caption to the user for confirmation before an action is performed.

Namespace: System.Management.Automation.Provider
Assembly: System.Management.Automation (in System.Management.Automation.dll)

Dim instance As CmdletProvider
Dim verboseDescription As String
Dim verboseWarning As String
Dim caption As String
Dim returnValue As Boolean

returnValue = instance.ShouldProcess(verboseDescription, verboseWarning, caption)

Public Function ShouldProcess ( _
	verboseDescription As String, _
	verboseWarning As String, _
	caption As String _
) As Boolean
public boolean ShouldProcess (
	String verboseDescription, 
	String verboseWarning, 
	String caption
public function ShouldProcess (
	verboseDescription : String, 
	verboseWarning : String, 
	caption : String
) : boolean



A description of the action to be performed. This description is displayed to the user for ActionPreference.Continue.


A query of whether the action should be performed, usually in the form of a question. This query is displayed to the user for ActionPreference.Inquire.


The caption for the confirmation message. This caption may or may not be displayed by the host.

Return Value

A Boolean value that indicates true when the user wants the provider to perform the operation. If false is returned, the operation should not be performed and the provider should move to the next resource.

Exception typeCondition

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

Also, if the pipeline was terminated because of ActionPreference.Stop or ActionPreference.Inquire, the command failure will ultimately be ActionPreferenceStopException.

To call this method, the provider must specify that it supports calls to the ShouldProcess(String,String,String) method when the CmdletProvider attribute is declared.

When the provider calls the ShouldProcess(String,String,String) method, the Windows PowerShell runtime handles any command-line settings or preference variables when it determines what is shown to the user or what should be returned.

Windows PowerShell provides two methods that the Windows PowerShell provider can call to confirm an operation with the user: ShouldProcess and ShouldContinue. The second method, the ShouldContinue method, is used to get a confirmation from the user in cases where the change is significant or when you want to provide yes-to-all and no-to-all options to the user. In addition, in contrast to ShouldProcess calls, a call to ShouldContinue is not affected by command-line settings or preference variables; the query is always displayed to the user.

For more information about Windows PowerShell providers, see Windows PowerShell Providers.

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


Target Platforms

Windows 98, Windows 2000, Windows 2000 Server, Windows CE, Windows Server 2008, Windows 98 Second Edition, Pocket PC, Smart Phone, Windows Server 2003, Windows XP Professional, Windows Vista, Windows Server 2003 R2, Windows XP, Windows 7, Windows 2008 R2, Windows Developer Preview, Windows Server Developer Preview

Send comments about this topic to Microsoft.
© 2014 Microsoft