# \`-WhatIf\` in Your Own Tools

SupportsShouldProcess in \[CmdletBinding()\] gives a function -WhatIf and -Confirm, and wrapping each change in if ($PSCmdlet.ShouldProcess(target, action)) makes it print a What if: line instead of changing anything, or ask before each change, exactly like Remove-Item.

![Cheat sheet for the lesson \`-WhatIf\` in Your Own Tools: SupportsShouldProcess in \[CmdletBinding()\] gives a function -WhatIf and -Confirm, and wrapping each change in if ($PSCmdlet.ShouldProcess(target, action)) makes it print a What if: line instead of changing anything, or ask before each change…](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/114cb2afd27a45db97e0a29b133cd078.webp)

- Category: PowerShell
- Level: Freelancer
- Tags: advanced-function, powershell, shouldprocess, supportsshouldprocess, whatif-and-confirm
- Updated: November 10, 2026

Source: https://www.ask-codey.com/cheat-sheets/powershell-supports-should-process-cheat-sheet
