open ports $system_ports = Get-NetTCPConnection -State Listen $text_port = Get-Content -Path C:\Users\Administrator\Desktop\ports.txt foreach($port in $text_port){ if($port -in $system_ports.LocalPort){ echo $port } }