.oO turn on ~ tune in ~ drop out Oo.
PowerShell Port Scanner
PowerShell Port Scanner

PowerShell Port Scanner

If you would like to use a PowerShell script acting as a Port Scanner, you can use the following script to quickly test the most common TCP ports or to test specific ports you need to enter manually.

Clear-Host

Write-Host `r
Write-Host "********************************" -ForegroundColor Green
Write-Host "* PowerShell Port Scanner v1.0 *" -ForegroundColor Green
Write-Host "********************************" -ForegroundColor Green
Write-Host `r`n`

$target=Read-Host ":\> Enter target IP address" 
$targetchar=($target.Length)
$targetspace=(16 - $targetchar)
$port=Read-Host ":\> Enter port numbers manually (separated by commas) or press ENTER for common TCP ports (20,21,22,23,25,53,80,389,443,3389)"

Write-Host `r`n`r`n
Write-Host "IP Address        Port       Status" -ForegroundColor Green
Write-Host "*******************************************" -ForegroundColor Green

if (($p=Test-NetConnection $target -WarningAction SilentlyContinue).PingSucceeded -eq $true) 
{
Write-Host $target $(' ' * $targetspace) "ICMP" $(' ' * 5) "Ping succeeded" -ForegroundColor Green
}
else 
{
Write-Host $target $(' ' * $targetspace) "ICMP" $(' ' * 5) "Ping failed" -ForegroundColor Red
}
Write-Host `r

if (!$port){
$port="20,21,22,23,25,53,80,389,443,3389"
    }

$port.split(',') | Foreach-Object -Process {
$portchar=($_.Length)
$portspace=(9 - $portchar)

If (($a=Test-NetConnection $target -Port $_ -WarningAction SilentlyContinue).tcpTestSucceeded -eq $true) 
{
Write-Host $target $(' ' * $targetspace) $a.RemotePort $(' ' * $portspace) "Open" -ForegroundColor Green
}
else 
{
Write-Host $target $(' ' * $targetspace) $a.RemotePort $(' ' * $portspace) "Closed" -ForegroundColor Red
}

}

Inspirational credits:
https://sid-500.com/2017/11/12/test-port-use-powershell-as-a-port-scanner/