ICommandRuntime.ShouldProcess Method (String, String)

 

Updated: April 27, 2016

Applies To: Windows PowerShell

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.

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

bool ShouldProcess(
	string target,
	string action
)

Parameters

target
Type: System.String

The name of the resource the cmdlet wants to change.

action
Type: System.String

The action the cmdlet wants to perform.

Return Value

Type: System.Boolean

A Boolean value that indicates true if the user wants the cmdlet to continue; false indicates that the cmdlet should not continue.

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: