12 lines
367 B
PowerShell
12 lines
367 B
PowerShell
$lines = netstat -ano | Select-String ":7000 "
|
|
foreach ($line in $lines) {
|
|
$parts = $line.ToString().Trim() -split '\s+'
|
|
$pid_val = $parts[-1]
|
|
if ($pid_val -match '^\d+$') {
|
|
Stop-Process -Id ([int]$pid_val) -Force -ErrorAction SilentlyContinue
|
|
Write-Host "Killed PID $pid_val"
|
|
}
|
|
}
|
|
Start-Sleep -Seconds 2
|
|
Write-Host "Port 7000 cleared"
|