Skip to content

Instantly share code, notes, and snippets.

@billerby
Created February 15, 2017 13:26
Show Gist options
  • Save billerby/fca5d560476d90d107eaf1c4a8460bb3 to your computer and use it in GitHub Desktop.
Save billerby/fca5d560476d90d107eaf1c4a8460bb3 to your computer and use it in GitHub Desktop.
# Powershell script to find processes that got stuck spawned by Alfresco Transformation Server and kill them.# # Get list of processes matching the name and older than x minutes where the cpu load is less than 1.50 (indicates its idle).# WINWORD idle process
$orphanProcs = get-process | where {($_.Name -eq "winword") -and ($_.StartTime -lt (get-date).addseconds(20))-and ($_.cpu -lt 1.50)}
#Check if list is Null and if not kill them all:
If ($orphanProcs) {
#display list
$orphanProcs
#kill list
$orphanProcs | foreach { $_.Kill() }
} Else {
echo "no processes found older than specified"
}
# WINWORD taking much more time than needed
$wordHangingProcess = get-process | where {($_.Name -eq "winword") -and ($_.StartTime -lt (get-date).addseconds(200))}
If ($wordHangingProcess) {
$wordHangingProcess | foreach { $_.Kill() }
}
Else {
echo "no wordHangingProcess found older than specified"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment