CmdletProvider.ShouldProcess Method

Confirms an operation with the user by sending a query to the user. The variants of this method can be used to send the name of the resource to be changed; send the resource name and the action to be taken; and send a description of the action to be taken, a query asking whether the action should be taken, and a caption.

This method returns a Boolean value that the provider can use to determine whether it should perform an operation on a resource. Providers that make changes to the system, such as deleting files or stopping services, should call this method to give the user the opportunity to confirm an action before it is taken.

Windows PowerShell provides should-process and should-continue functionality to providers. Although both processes can be used to send a query to the user, a call to the System.Management.Automation.Provider.CmdletProvider.ShouldProcess method can be affected by preference settings and command-line parameters that can specify whether the query is or is not displayed to the user. In contrast, a call to the System.Management.Automation.Provider.CmdletProvider.ShouldContinue method is not affected by preference settings or command-line parameters; the query is always displayed to the user.

For more information about providers, see Windows PowerShell Providers.

NameDescription
CmdletProvider.ShouldProcess (String)Confirms the operation with the user, sending the name of the resource to be changed to the user for confirmation before the operation is performed.
CmdletProvider.ShouldProcess (String, String)Confirms the operation with the user, sending the name of the resource to be changed and the action to be performed to the user for confirmation before the operation is performed.
CmdletProvider.ShouldProcess (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.
CmdletProvider.ShouldProcess (String, String, String, ShouldProcessReason)Confirms an operation with the user sending a description of the action to be performed, a query asking if the action should be performed, a caption for the query window, and the reason for the query.

Send comments about this topic to Microsoft.
Show:
© 2014 Microsoft