ICommandRuntime.ShouldProcess Method

 

Updated: April 27, 2016

Applies To: Windows PowerShell

Requests confirmation from the user before an action is taken. The variants of this method can be used to display the name of the resource to be changed, display the resource name and the action to be taken, and more.

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

NameDescription
System_CAPS_pubmethodShouldProcess(String)

Requests confirmation with the user by displaying the name of the resource to be changed, provided by the cmdlet, and returning an answer based on the user feedback.

System_CAPS_pubmethodShouldProcess(String, String)

Requests confirmation with the user by displaying the name of the resource to be changed and the action to be taken, provided by the cmdlet, and returning an answer based on the user feedback.

System_CAPS_pubmethodShouldProcess(String, String, String)

Requests confirmation with the user by displaying the action to be taken, a query asking if the cmdlet should continue, a caption for the prompt, and returning an answer based on the user feedback.

System_CAPS_pubmethodShouldProcess(String, String, String, ShouldProcessReason)

Requests confirmation with the user by displaying the action to be taken, a query asking if the cmdlet should continue, a caption for the prompt, and returning an answer based on the user feedback and the reason why false is returned.

Cmdlets call ShouldProcess before the cmdlet makes a change to the system, such as deleting files or stopping services.

The implementation of this method should take into account command-line settings and preference variables in determining whether it should prompt the user and what it should return.

Return to top

Community Additions

ADD
Show: