The nice thing is that in PowerShell, unlike bash, this flows through to the vast majority of other commands. If the script has the snippet above, then you don't have to litter it with "if ( $userSaidYes ) { ... }" blocks all over the place.
Similarly, PowerShell automatically wires up logic to produce all of the useful modes you might want:
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend
This is very fiddly to implement manually, and "Suspend" is likely impossible for most shells.
The following prefix in a ps1 script enables the -WhatIf and -Confirm parameters:
To enable -Confirm by default for scary scripts, just use: The nice thing is that in PowerShell, unlike bash, this flows through to the vast majority of other commands. If the script has the snippet above, then you don't have to litter it with "if ( $userSaidYes ) { ... }" blocks all over the place.Similarly, PowerShell automatically wires up logic to produce all of the useful modes you might want:
This is very fiddly to implement manually, and "Suspend" is likely impossible for most shells.See: https://docs.microsoft.com/en-us/powershell/scripting/learn/...