Export (0) Print
Expand All

Cmdlet.ShouldProcess Method

Requests confirmation from the user before an operation is performed. The variants of this method can be used to send the name of the resource to be changed, send the name of the resource and the operation to be performed, and more. The confirmation message that is displayed to the user is based on which variant of this method is called.

There is no preferred variant of this method that should be used. Choose the variant that displays the appropriate confirmation message for your situation. For more information about the different confirmation messages that can be displayed, see Confirmation Messages. For code examples, see the topics for each variant of this method.

Depending on the current environment, ShouldProcess might, or might not, prompt the user. For more information about confirmation requests, including information about how confirmation requests are affected by the $ConfirmPreference shell variable, see Requesting Confirmation.

For more information about cmdlets, see Windows PowerShell Cmdlets.

NameDescription
Cmdlet.ShouldProcess (String)Requests confirmation from the user before an operation is performed. This method sends the name of the resource to be changed so that the user can decide if the operation should continue.
Cmdlet.ShouldProcess (String, String)Requests confirmation from the user before an operation is performed. This method sends the operation that is to be performed and the name of the resource to be changed so that the user can decide if the operation should continue.
Cmdlet.ShouldProcess (String, String, String)Requests confirmation from the user before an operation is performed. This method sends a description of the operation to be performed, a warning message that can include query, and a caption for the warning message.
Cmdlet.ShouldProcess (String, String, String, ShouldProcessReason)Requests confirmation from the user before an operation is performed. This method sends a detailed description of the resource to be changed and the operation to be performed to the user for confirmation before the operation is performed.

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