Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to compare int32 values (ranges) for overlaps

$
0
0
Wonder it someone could answer this for me. How I can compare all results in ConvertTo-DecimalIP (note there will be 000's to see if any of the int32 values would be in each of the ranges. Note each split is start/end of one single range, I'm looking for overlaps. Yes this is an SCCM thing, but figured the question was more for the powersehll forum. Thank you in advance.
function get_data
{

    $wmi = gwmi -Namespace "root\sms\site_XXX" -Class sms_boundary -Filter "boundarytype='3'" | Select-Object -ExpandProperty value #3 = IP Address Range
           $Target= @()
    foreach($i in $wmi)
    {
        $target += $i    
    }
    foreach($first in $Target)
    {
    $result = $first.split('-')
        foreach($res in $result)
        {
            #Write-Host $res
            ConvertTo-DecimalIP $res
        }
    }

}




Function ConvertTo-DecimalIP {
     
  [CmdLetBinding()]
  Param(
    [Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)]
    [Net.IPAddress]$IPAddress
  )

  Process {
    $i = 3; $DecimalIP = 0;
    $IPAddress.GetAddressBytes() | ForEach-Object { $DecimalIP += $_ * [Math]::Pow(256, $i); $i-- }

   return [UInt32]$DecimalIP
  }
}

get_data



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>