Function Get-ScanIPRange {
Param (
[Parameter (Mandatory=$true)]
[string]
$StartScanIP,
[string]
$EndScanIP
)
$ScanIPRange = @()
if (-not([string]::IsNullOrEmpty($EndScanIP))) {
$StartIP = $StartScanIP -split '\.'
[Array]::Reverse($StartIP)
$StartIP = ([System.Net.IPAddress]($StartIP -join '.')).Address
$EndIP = $EndScanIP -split '\.'
[Array]::Reverse($EndIP)
$EndIP = ([System.Net.IPAddress]($EndIP -join '.')).Address
For ($x=$StartIP; $x -le $EndIP; $x++) {
$IP = [System.Net.IPAddress]$x -split '\.'
[Array]::Reverse($IP)
$ScanIPRange += $IP -join '.'
}
}
else {
$ScanIPRange += $StartScanIP
}
Return $ScanIPRange
}