I'm trying to use two arrays to compare ipsubnets and ip-ranges but can't seem to work out why when I try comparing say "192.168.0.10 - 192.168.10 against "10.152.0.1-10.152.0.10 the script reports a match? Can anyone shed what I'm missing?
function get_data
{
$wmi = gwmi -Namespace "root\sms\site_XXX" -Class sms_boundary -Filter "boundarytype='3'" | Select-Object -ExpandProperty value
$Target= @()
foreach($i in $wmi)
{
$target += $i
}
$wmi = gwmi -Namespace "root\sms\site_XXX" -Class sms_boundary -Filter "boundarytype='0'" | Select-Object -ExpandProperty value
$Target1= @()
foreach($i1 in $wmi)
{
$target1 += $i1
}
foreach($first in $Target)
{
if($Target1 -contains $first)
{
write-host "No Overlap First not in second array" $first
}
else
{
write-host "Overlap First in second array" $first
}
}
foreach($first1 in $Target1)
{
if($Target -contains $first1)
{
write-host "No Overlap First not in second array" $first1
}
else
{
write-host "Overlap First in second array" $first1
}
}
}
get_data