Kill IntelliJ java processes (when stopping an Tomcat debug session in IntelliJ some processes were not killed and kept blocking port 1099)
#Get-WmiObject Win32_Process -Filter "name = 'java.exe'" | select ProcessId, ThreadCount, CommandLine
$processes = Get-WmiObject Win32_Process -Filter "name = 'java.exe'"
foreach($proc in $processes)
{
if($proc.CommandLine.Contains("IntelliJ"))
{
Write-Host "stopping proccess $($proc.ProcessId) with $($proc.ThreadCount) threads; $($proc.CommandLine.Substring(0, 50))..."
Stop-Process -F $proc.ProcessId
} else
{
Write-Host "skipping proccess $($proc.ProcessId) with $($proc.ThreadCount) threads; $($proc.CommandLine.Substring(0, 50))..."
}
}