How to check if a process is exited from the system after executing Stop-Process command in PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

After killing the process using Stop-Process command in PowerShell, you can determine if the process is really terminated from the system with HasExited function.

For example, we will kill Notepad process and check if Notepad process still exists in the system?

$notepad = Get-Process notepad | Stop-Process
if($notepad.HasExited){"Process is terminated"}
else{"Process is still running"}

raja
Published on 22-Jan-2020 12:30:25
Advertisements