Skip to content

Instantly share code, notes, and snippets.

@ctrl-freak
Created May 18, 2023 03:35
Show Gist options
  • Save ctrl-freak/f4ab227381a85d80c8b1f97953114e6f to your computer and use it in GitHub Desktop.
Save ctrl-freak/f4ab227381a85d80c8b1f97953114e6f to your computer and use it in GitHub Desktop.
Check whether process hung and kill or return non-zero
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