Cmdlet.ShouldContinue Method (String, String, Boolean, Boolean)
Updated: April 27, 2016
Applies To: Windows PowerShell
Requests confirmation of an operation from the user by sending a second query to the user with yesToall and noToall options.
Assembly: System.Management.Automation (in System.Management.Automation.dll)
public bool ShouldContinue( string query, string caption, ref bool yesToAll, ref bool noToAll )
Query that inquires whether the cmdlet should continue.
Caption of the window that might be displayed when the user is prompted whether or not to perform the action. It might be displayed by some hosts, but not by all hosts.
True if and only if the user selects the yesToall option. If this is already True,will bypass the prompt and return True.
True if and only if the user selects the noToall option. If this is already True,will bypass the prompt and return False.
The pipeline is stopped. The pipeline was terminated either before the call was made or while the call was in progress. By default, the cmdlet should allow the caller of the processing record method to catch this exception.
Also, if the pipeline was terminated because of ActionPreference.Stop or ActionPreference.Inquire, the command failure will ultimately be ActionPreferenceStopException.
The call cannot be completed at this time or cannot be completed from this thread. For more information, see the following Remarks section.
A call to the ShouldContinue method is not affected by preference settings or command-line parameters; the query is always displayed to the user.
Cmdlets callingshould also implement a Force parameter that allows the cmdlet to bypass these calls. If this is not done, it will be difficult to use the cmdlet from scripts and noninteractive hosts.
This method can be called only from within the cmdlet implementation of the BeginProcessing, ProcessRecord, and EndProcessing methods and only from that thread. If this call is made from outside these implementations or from another thread, an InvalidOperationException exception is thrown.
For more information about cmdlets, see Windows PowerShell Cmdlets.
In the following code example, the call to Yes To All to the first confirmation message.does not specify a caption or query so the default text is displayed. In addition, the yesToAll parameter is set to true, which means that the second message is displayed only if the user answered