I have a powershell function that processes a list of files. For this, I use blocks begin, processand end:
begin {
}
process {
}
end {
}
Now that I hit Ctrl+C, the whole script just ends right where it was. This is not a problem for part of the process, as it will only make permanent changes to the most recent team.
However, I still want to execute whats in the block endin order to clean it up a bit and print some statistics about the files that were processed.
Is there a clean way to catch keyboard interrupts while maintaining a start / process / end structure?
source
share