Need a powershell script to scan the status of system port in remote machine

Hi Friends,

I need a script to fetch the status of TCP port connection from Source machine with respective destination and port details.

Source_Name Source_IP Destination_Name Destination_IP Portocol Port Status
Server_1 Destination_1 TCP 20501 Opened/Closed
Server_1 Destination_2 TCP 80 Opened/Closed
Server_1 Destination_3 TCP 1417 Opened/Closed
Server_1 Destination_4 TCP 9997 Opened/Closed
Server_1 Destination_5 TCP 25051 Opened/Closed
Server_2 Destination_1 TCP 80 Opened/Closed
Server_2 Destination_2 TCP 80 Opened/Closed
Server_2 Destination_3 TCP 443 Opened/Closed
Server_2 Destination_4 TCP 80 Opened/Closed
Server_2 Destination_5 TCP 9997 Opened/Closed
Server_3 Destination_1 TCP 80 Opened/Closed
Server_3 Destination_2 TCP 80 Opened/Closed
Server_3 Destination_3 TCP 443 Opened/Closed
Server_3 Destination_4 TCP 80 Opened/Closed
Server_3 Destination_5 TCP 9997 Opened/Closed

The above given data are stored in CSV as a file name called “firewall.csv”

From my desktop I need to generate a report of the status Port availability with respect to destination name or IP. But this should check with source name or IP and not in my desktop. Basically Source machine varies like development, testing and Production for all these severs I will not have login permission to do telnet individually. So from my desktop I need to pull the telnet report of all the source machine with their respective destination and port details as given above.

  1. Here the challenges is to skip the authentication while scanning the source machine. Because I don’t have privilege for Prod machines. When I try to run the TCP Connection script I am getting an error like, " Access denied,PSSessionStateBroken. Conencting to remote server failed with the following message:ACCESS DENIED ".

  2. It should not scan my local desktop, it has to scan the source machine with their respective destination and port details.


If you don’t have permission, then you can’t do this. The whole point of security is to stop unauthorized people from gaining this information. An intruder could simply scan machines and figure out what was available, otherwise.