I'm trying to figure out why my "$count--" is incrementing the integer down by 2 every time it cycles to a new IP. I want this to count down by 1 every time a new IP is being checked.
function scrape {
$PortList = @(443, 4433, 444, 433, 4343, 4444, 4443)
$IPList = $text1.text.split("`r")
$IPList = $text1.text.split()
$count = ($IPList.Count - 1)/2
Write-Host $IPList
Write-Host 'Firewalls with open ports will be listed here as they are discovered. Please wait while the script' `n 'processes the list of IP addresses. There are'$count 'IP addresses to check'
foreach ($IP in $IPList) {
$count--
foreach ($Port in $PortList) {
$url = "https://${IP}:${Port}"
$verb = 'GET'
$SiteData = try{httpget $url $verb}Catch{Continue}
If ($SiteData.Contains("auth1.html")) {
Write-Host ('https://' + $IP + ':' + $Port + " MGMT " + $IP) -ForegroundColor Red
$text2.text += ('https://' + $IP + ':' + $Port + " MGMT " + $IP + "`n")
}
Else {
If ($SiteData.Contains("SSLVPN")) {
Write-Host ('https://' + $IP + ':' + $Port + " SSLVPN " + $IP)
$text2.text += ('https://' + $IP + ':' + $Port + " SSLVPN " + $IP + "`n")
}
Else {
Write-Host ('https://' + $IP + ':' + $Port + " OTHER " + $IP)
$text2.text += ('https://' + $IP + ':' + $Port + " OTHER " + $IP + "`n")
}
}
}
}
}
EDIT/UPDATE: Okay so I figured out that the loop is counting blank space between the IP addresesses as a member of the array, which is causing that double decrement. Now I just have to figure out how to have it only count the addresses.