I've found the PowerShell script below to check whether a port on a server is open or not but how do I make it so that I can run this against a list of servers and a list of ports stored in txt files? How can I search UPD and TCP lists? Foreach?
$Servername = Read-Host "Enter the Servername" $PortNumber = Read-Host "Enter the Port Number" $K = .\PortQry.exe -n $Servername -e $PortNumber -p TCP $L = $K -Match "LIS?" If($L -ne $null) { $res = $servername + " has " + $PortNumbe + "Opened" Write-Host $res } Else { $res = $servername + " has " + $PortNumbe + "Closed" Write-Host $res }