Safety and Help

Safety and Help: `-WhatIf` in Your Own Tools, Help for Your Tool.

Updated

  1. `-WhatIf` in Your Own Tools (Freelancer): 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.
  2. Help for Your Tool (Journeyman): A comment block at the top of a function, with keywords such as .SYNOPSIS, .DESCRIPTION, .PARAMETER and .EXAMPLE, becomes the function's help page, so Get-Help, -Examples and -Parameter explain your tool the way they explain PowerShell's own commands.