How to check if a process is runnin and stop it using PowerShell

Configurare noua (How To)

Situatie

How to check if a process is runnin and stop it using PowerShell script.

Solutie

$calculator = Get-Process calc -ErrorAction SilentlyContinue
if ($calculator) {
echo “running”
Stop-Process -processname “calc” -Force
echo “calc process stopped”
}
else {
echo “not running”
}
Remove-Variable calculator

Tip solutie

Permanent

Voteaza

(6 din 14 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?