title: File Name Contains Certain Text
body: <p>I know this is a new guy question, but I cant find anything. I think the issue might have to do with variable type issue?</p>
  
  <p>I'm trying to look at a files name and see if  pattern1 is contained in the file name. If so then replace the pattern text with "TEST".</p>
  
  <p>Right now it doesn't error out, but it skips the <code>IF</code>, I do have files with the pattern in the directory. </p>
  
  <p>Can't insert actually code, so here is a sample</p>
  
  <pre><code>$pattern1 = "January"
  $pattern2 = "December 31"
  $path = "C:\Users\...\METRICS-TEST\Metrics 2014\January 2014 Client Metrics"
  
  $search_results = Get-ChildItem -Path $path | Where-Object { ((! $_.PSIsContainer))}
  foreach ($file in $search_results) {
      if($file.Name -contains $pattern1){
          $new_name = $file.Name -replace $pattern1, "TEST1"
          Rename-Item -Path $file.FullName -NewName $new_name
      }else{
          $new_name = $file.Name -replace $pattern2, "TEST2"
          Rename-Item -Path $file.FullName -NewName $new_name
      }
  }
  </code></pre>