xxxxxxxxxx
Stop-Process -Name "foo" -Force
Stop-Process -Id 0000 -Force
xxxxxxxxxx
# Specify the process name or ID you want to kill
$processNameOrId = "notepad.exe"
# Get the process associated with the specified name or ID
$process = Get-Process -Name $processNameOrId -ErrorAction SilentlyContinue
if ($process -eq $null) {
Write-Host "Process not found."
}
else {
# Kill the process
$process | ForEach-Object { $_.Kill() }
Write-Host "Process terminated."
}