function test-port {
$computer = Read-Host "computername | IP Address?"
$port = read-host "port numbers? Separate them by comma"
$port.Split(',') | ForEach-Object -Process {
If (($a = Test-NetConnection $computer -port $_ -WarningAction SilentlyContinue).tcptestsucceeded -eq $true) {
Write-Host $a.computername $a.remoteport -ForegroundColor Green -Separator " ==> "
}
else {
Write-Host $a.computername $a.remoteport -Separator " ==> " -ForegroundColor Red
}
}
}