Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Confirmation Messages

 

Here are different confirmation messages that can be displayed depending on the variants of the Overload:System.Management.Automation.Cmdlet.ShouldProcess and Overload:System.Management.Automation.Cmdlet.ShouldContinue methods that are called.


System_CAPS_importantImportant

For sample code that shows how to request confirmations, see How to Request Confirmations.

You can specify the resource that is about to be changed by calling the Cmdlet.ShouldProcess method. In this case, you supply the resource by using the target parameter of the method, and the operation is added by Windows PowerShell. In the following message, the text “MyResource” is the resource acted on and the operation is the name of the command that makes the call.

Confirm
Are you sure you want to perform this action?
Performing operation "Test-RequestConfirmationTemplate1" on Target "MyResource".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):

If the user selects Yes or Yes to All to the confirmation request (as shown in the following example), a call to the Overload:System.Management.Automation.Cmdlet.ShouldContinue method is made, which causes a second confirmation message to be displayed.

Confirm
Are you sure you want to perform this action?
Performing operation "Test-RequestConfirmationTemplate1" on Target "MyResource".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y

Confirm
Continue with this operation?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"):

You can specify the resource that is about to be changed and the operation that the command is about to perform by calling the Cmdlet.ShouldProcess method. In this case, you supply the resource by using the target parameter and the operation by using the target parameter. In the following message, the text “MyResource” is the resource acted on and “MyAction” is the operation to be performed.

Confirm
Are you sure you want to perform this action?
Performing operation "MyAction" on Target "MyResource".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):

If the user selects Yes or Yes to All to the previous message, a call to the Overload:System.Management.Automation.Cmdlet.ShouldContinue method is made, which causes a second confirmation message to be displayed.

Confirm
Are you sure you want to perform this action?
Performing operation "MyAction" on Target "MyResource".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y

Confirm
Continue with this operation?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"):
Show: