title: Matching Something Against Array List Using Where Object
body: <p>I've found multiple examples of what I'm trying here, but for some reason it's not working.</p>
  
  <p>I have a list of regular expressions that I'm checking against a single value and I can't seem to get a match.</p>
  
  <p>I'm attempting to match domains. e.g. gmail.com, yahoo.com, live.com, etc.</p>
  
  <p>I am importing a csv to get the domains and have debugged this code to make sure the values are what I expect. e.g. "gmail.com"</p>
  
  <p><strong>Regular expression examples AKA $FinalWhiteListArray</strong></p>
  
  <pre><code>(?i)gmail\.com
  (?i)yahoo\.com
  (?i)live\.com
  </code></pre>
  
  <p><strong>Code</strong></p>
  
  <pre><code>Function CheckDirectoryForCSVFilesToSearch {
  
      $global:CSVFiles = Get-ChildItem $Global:Directory -recurse -Include *.csv | % {$_.FullName} #removed -recurse
  }
  
  Function ImportCSVReports {
      Foreach ($CurrentChangeReport in $global:CSVFiles) {
          $global:ImportedChangeReport = Import-csv $CurrentChangeReport
      }
  }
  Function CreateWhiteListArrayNOREGEX {
      $Global:FinalWhiteListArray = New-Object System.Collections.ArrayList
      $WhiteListPath = $Global:ScriptRootDir + "\" + "WhiteList.txt"
      $Global:FinalWhiteListArray= Get-Content $WhiteListPath
  }
  $Global:ScriptRootDir = Split-Path -Path $psISE.CurrentFile.FullPath
  $Global:Directory = $Global:ScriptRootDir + "\" + "Reports to Search" + "\" #Where to search for CSV files
  
  CheckDirectoryForCSVFilesToSearch
  ImportCSVReports
  CreateWhiteListArrayNOREGEX
  
  Foreach ($Global:Change in $global:ImportedChangeReport){
      If (-not ([string]::IsNullOrEmpty($Global:Change.Previous_Provider_Contact_Email))){
         $pos = $Global:Change.Provider_Contact_Email.IndexOf("@")
         $leftPart = $Global:Change.Provider_Contact_Email.Substring(0, $pos)
         $Global:Domain = $Global:Change.Provider_Contact_Email.Substring($pos+1)
  
         $results = $Global:FinalWhiteListArray | Where-Object { $_ -match $global:Domain}
  }
  
  }
  </code></pre>
  
  <p>Thanks in advance for any help with this.</p>