Powershell Array search for keys

powershell

I Have an array called $a

echo $a gives:

url                                                               load                                                             
---                                                               ----                                                             
win-coll2.astest.org                                              9                                                                
win-coll.astest.org                                               110                                                              
win-coll4.astest.org                                              110                                                              
win-coll5.astest.org                                              140                                                              
win-coll3.astest.org                                              410 

now i want to know, if the array contains a sting
eg:
win-coll2.astest.org should lead to true
and win-coll7.astest.org should lead to false

is there a proper way to do this without a foreach?

with foreach:

$IsInArray = false
$ProofString = "win-coll2.astest.org"
foreach( $item in $a){
  if($item.url -eq $ProofString){
    $IsInArray = true
  }
}

Best Answer

In powershell v4 (and possibly v3) you can do the following:

[PS] > $a.url -contains 'win-coll2.astest.org'
True
[PS] > $a.url -contains 'win-coll7.astest.org'
False

Otherwise, I think the easiest, least painful way is either do a foreach or a foreach-object...