ICommandRuntime.ShouldProcess Method (String, String, String, ShouldProcessReason)
Assembly: System.Management.Automation (in System.Management.Automation.dll)
'Usage Dim instance As ICommandRuntime Dim verboseDescription As String Dim verboseWarning As String Dim caption As String Dim shouldProcessReason As ShouldProcessReason Dim returnValue As Boolean returnValue = instance.ShouldProcess(verboseDescription, verboseWarning, caption, shouldProcessReason)
bool ShouldProcess ( string verboseDescription, string verboseWarning, string caption, out ShouldProcessReason shouldProcessReason )
boolean ShouldProcess ( String verboseDescription, String verboseWarning, String caption, /** @attribute OutAttribute() */ /** @ref */ ShouldProcessReason shouldProcessReason )
A description of the action the cmdlet wants to perform. This is what is displayed to the user for ActionPreference.Continue.
A query that asks whether the action should be performed. This is what is displayed to the user for ActionPreference.Inquire.
The caption to display as part of the prompt (such as the window title in a dialog box).
A ShouldProcessReason constant that specifies the reason why false is returned. See Remarks for more information.
Return ValueReturns a Boolean value that indicates true if the user wants the cmdlet to continue; false indicates not to continue.
This method allows the cmdlet to learn whether Cmdlet.ShouldProcess returned false because the cmdlet was invoked using the WhatIf parameter (or, equivalently, the $WhatIfPreference shell variable). However, it is unusual that the cmdlet needs to know the reason why false was returned, so most interfaces should implement ShouldProcess(String,String,String). For more information about confirmation requests, including information about how confirmation requests are affected by the $ConfirmPreference shell variable, see Requesting Confirmation.
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.
Target PlatformsWindows Developer Preview, Windows Server Developer Preview
Send comments about this topic to Microsoft.