If all the ports you're testing use TCP and not another protocol like ICMP the try using .Net's System.Net.Sockets.TcpClient. Here's just one of the examples you can find: fast-tcp-port-check-in-powershell.html
You can also decrease the duration of your testing by introducing some level of parallelism into the process. Have a look at using Start-Job. Keep the number of concurrent jobs to a reasonable number (based on the capabilities of the machine from which you're running the script). Collect the data when the last job completes.