functions/utility/Disable-PSFConsoleInterrupt.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
function Disable-PSFConsoleInterrupt { <# .SYNOPSIS Prevents the use of CTRL+C from interrupting the console. .DESCRIPTION Prevents the use of CTRL+C from interrupting the console. Use this to prevent manual interruption of critical tasks, but do not forget to re-enable it as soon as possible. Usually, ctrl+C is a critical part of the user experience, enabling the user to interrupt the console and avoid a hang from locking the console. .EXAMPLE PS C:\> Disable-PSFConsoleInterrupt Prevents the use of CTRL+C from interrupting the console. #> [CmdletBinding()] param () [Console]::TreatControlCAsInput = $true } |