Created
May 18, 2023 03:35
-
-
Save ctrl-freak/f4ab227381a85d80c8b1f97953114e6f to your computer and use it in GitHub Desktop.
Check whether process hung and kill or return non-zero
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[String] $Process = 'gswin64c', | |
[Int] $MaxRunTime = -5 | |
) | |
try{ | |
Get-Process $Process -ErrorAction Stop | Where StartTime -lt (Get-Date).AddSeconds($MaxRunTime) | Stop-Process -Force | |
} catch { | |
# No process to kill, good to go | |
# Exit as non-zero so Boomi takes Try-Catch route and continues processing | |
exit 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment