top of page

Useful Script for Networking Test on PowerShell

We often need to test the network to investigate the source of the problem and must use our laptops to investigate the problem. Many companies have some rules to get installed the program on their computer. We can download Nmap (free network scanner), but due to company policy, we may be unable to install the program. How do we test the network with the resources we have?

I will share a few useful scripts for testing the network from your computer.

1- Continuous Ping with Timestamp;

ping.exe -t | ForEach {"{0} - {1}" -f (Get-Date),$_} > C:\Users\Desktop\ping_log.txt

2- Scan Network;

1..254 | ForEach-Object {Get-WmiObject Win32_PingStatus -Filter "Address='192.168.1.$_' and Timeout=100 and ResolveAddressNames='true' and StatusCode=0" | select ProtocolAddress*}

3- TCP Port Scan;

1..1024 | % {echo ((New-Object Net.Sockets.TcpClient).Connect("",$_)) "Open port - $_"} 2>$null

4- UDP Port Scan; Maybe you can test the TCP port with the telnet command, but you can't check whether the UDP port is open with telnet. This will do the job.

53 | % {echo ((New-Object Net.Sockets.UdpClient).Connect("",$_)) "Open port - $_"} 2>$null

5- Scan Some Ports;

443,22,80,23 | % {echo ((New-Object Net.Sockets.TcpClient).Connect("",$_)) "Open port - $_"} 2>$null

Thanks for Reading.

279 views2 comments
bottom of page