Did you try it like this
$url="http://server-name/folder/hosts_in_mm_list.txt"$file="c:\names.txt"$web=New-ObjectSystem.Net.WebClient$web.DownloadFile($url,$file)
$content=Get-Content$file
$tgtHosts="host1","host2","host3"
$tgtComment="Target comment"
$hostnames=$content|%{ $hostname,$comment=$_.Split(',') if($tgtHosts-contains$hostname-and$tgtComment-eq$comment){ $hostname
} }
If that doesn't work, can you attach the file you downloaded, so I can have a look how the content looks ?