添加清理端口脚本

This commit is contained in:
2024-04-28 20:20:28 +08:00
parent 310e061483
commit 4a13bd7d0d

13
script/freePort.ps1 Normal file
View File

@@ -0,0 +1,13 @@
$defaultPort = 7456
$userPort = Read-Host "enter port [$defaultPort]:"
if ($userPort -eq "")
{
$userPort = $defaultPort
}
Write-Host "free port: $userPort"
Get-NetTCPConnection -State Listen | Where-Object { $_.LocalPort -eq $userPort } | ForEach-Object { Get-Process -ID $_.OwningProcess } | Stop-Process