February 3, 2026
powershell

Powershell ile bir portu sürekli kontrol etme

Powershell ile bir portu sürekli kontrol ederek bir çalışma esnasında iki sunucu arasında connection var mı kontrol edebiliriz.

Powershell bir çok konuda hayatımızı kolaylaştırdığı gibi bu konuda biz sistem yöneticilerinin hayatını kolaylaştırmaktadır.

Aşağıdaki linkten Powershell ile gelişmiş port kontrol çalışmalarıma da bakmak isteyebilirsiniz.

Powershell Port Kontrol Komutu – Get-NetTCPConnection

Powershell ile Port Kontrol

$localaddress = "192.168.1.10" # Local bilgisayar ip - Get-NetIPAddress komutu ile pwh ip çekilebilir
$remoteaddress = "192.168.10.10" # Remote bilgisayar ip

Get-NetTCPConnection -State Listen,Established |Select-Object -Property LocalAddress,RemoteAddress,LocalPort,RemotePort,State |Where-Object {$_.LocalAddress -like $localaddress -and $_.RemoteAddress -eq $remoteaddress} |ft

for($i=1;1 -lt 1000; $i ++)

{
Get-NetTCPConnection -State Listen,Established |Select-Object -Property LocalAddress,RemoteAddress,LocalPort,RemotePort,State |Where-Object {$_.LocalAddress -like $localaddress -and $_.RemoteAddress -eq $remoteaddress} |ft

Start-Sleep -Seconds 2
}