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

(2 din 7 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?