I am starting a java process:
$global:TS = Start-Process -FilePath "$pathTS\jdk\bin\java.exe" -ArgumentList "-jar","`"$pathTS\TestServer.jar`"" -WorkingDirectory ` "$pathTS" ` -PassThru -WindowStyle Hidden
works fine so far.
Now I am trying to terminate that process:
Invoke-CimMethod -Query 'select * from Win32_Process where CommandLine like "Test-Server"' -MethodName "Terminate"
BTW: I cannot use the ID of the process to terminate it since it is changing somehow.
I am new to PS and now stuck. Maybe someone has in idea.
Thank you! Alex