(The content of this article is licensed under "CC-BY" which allows you to share, adapt, remix, and republish this work. All that's required is attribution like this: "© CC-BY <link to where you obtained this article>
").
More info at: https://creativecommons.org/licenses/by/4.0/
A PowerShell Design Pattern: Handling Confirmation Prompts in Cmdlets
When writing custom PowerShell Cmdlets, a common scenario arises when your Cmdlet has the SupportsShouldProcess = $true
attribute set to leverage PowerShell’s -Confirm
infrastructure. This attribute enables built-in confirmation prompts that ask the user to verify potentially impactful actions before proceeding.