How do I catch and handle Ctrl+C in a PowerShell script? I understand that I can do this from a cmdlet in v2 by including an override for the Powershell.Stop()
method, but I can't find an analog for use in scripts.
I'm currently performing cleanup via an end
block, but I need to perform additional work when the script is canceled (as opposed to run to completion).