How to Request Confirmations
|For more information about how Windows PowerShell handles these requests, see Requesting Confirmation from Cmdlets.|
To request confirmation
Ensure that the SupportsShouldProcess parameter of the Cmdlet attribute is set to true. (For functions this is a parameter of the CmdletBinding attribute.)
Add a Force parameter to your cmdlet so that the user can override a confirmation request.
Add a second if statement that uses the return value of the ShouldContinue method and the value of the Force parameter to determine whether the operation should be performed.
In the following code example, the ShouldProcess and ShouldContinue methods are called from within the override of the ProcessRecord method. However, you can also call these methods from the other input processing methods.
Other ResourcesWriting a Windows PowerShell Cmdlet