I want to scan my website and see which ports are opened, and the scan source should be external. There are some websites and services which provide a port scan, but with some limitations. So I wrote a PowerShell script to perform an external port scanning through one of these port scanning providers.
Table of Contents
Prerequisites
You need Windows PowerShell 5.1 or 7 and an internet connection. The service used in this tutorial is IP Finger Print, so make sure you can access this website and is not blocked.
This service is simple and free with no limitation “till the date of writing this post” maybe things will change in the future. Let me know.
Downloading PowerShell Port Scan Script
Feel free and download the script from my Github repo or by running the following PowerShell line
Install-Script -Name PortScan
Using PowerShell Port Scan Script
The script accepts the following parameters:
[String]HostToScan: The Name or IP address of the host to scan e.g. “www.powershellcenter.com” or 8.8.8.8
[ParameterSet=Range][Int]StartingPort: The first IP to scan on a range e.g 25
[ParameterSet=Range][Int]EndingPort: The last IP to scan on a range e.g 80
[ParameterSet=SelectivePort][Int]SelectivePort: A set of custom ports to scan e.g 25,80,443
For example, to scan www.powershellcenter.com for all open ports starting from port 25 till 80, use the following code
PortScan.ps1 -HostToScan 'www.powershellcenter.com' -StartingPort 25 -EndingPort 80
The output looks like
Dont use the PowerShell port scan script to scan a hug range as it might delay the result and cause unexpected results. And dont forget that the script depend on an external service to do the scan so something things go creepy there 🙂
To scan custom ports for example 25,80,443,555,888 run the following code
PortScan.ps1 -HostToScan 'www.powershellcenter.com' -SelectivePort 25,80,443,555,888
The results look like the following
Host Port Result
---- ---- ------
www.powershellcenter.com 25 Open
www.powershellcenter.com 80 Open
www.powershellcenter.com 443 Open
www.powershellcenter.com 555 Filtered
www.powershellcenter.com 888 Filtered
This script is only for personal use and I am not responsible for any miss-use
More features will be added in the soon future. Feel free and comment below on which feature you like to include, or get a Github fork and update what you wish.