title: if loop not seems to be working
body: <p>I have a code as given below:</p>
  
  <pre class="lang-psh prettyprint-override"><code>$datearray = @()
  $temp = Get-Content "C:\temp.txt"
  $temp1 = Get-Content "C:\temp1.txt"
  foreach ($te in $temp) {
    $t = $te -split '-'
    $da = $t[1]
    $mo = $t[2]
    $yea = $t[3]
    $fulldate = "$da-$mo-$yea"
    if ($temp1 -match $fulldate) {
      if ($fulldate -match $te) {
        $datearray += $_
        $fmt     = 'dd-MM-yy-HH-mm'
        $culture = [Globalization.CultureInfo]::InvariantCulture
        *!* $datearray | sort { [DateTime]::ParseExact(($_ -split '-', 2)[1], $fmt, $culture) } | select -Last 1 | Add-Content "c:\temp4.txt"
      } else {
        #some operation
      }
    } else {
      #some operation
    }
  }
  </code></pre>
  
  <p>For your understanding, I will show you how <code>temp1.txt</code> looks like:</p>
  
  <pre class="lang-none prettyprint-override"><code>17-07-15
  18-07-15
  19-07-15
  20-07-15
  21-07-15
  22-07-15
  23-07-15
  </code></pre>
  
  <p><code>temp.txt</code> is:</p>
  
  <pre class="lang-none prettyprint-override"><code>testdatabase-17-07-15-22-00
  testdatabase-17-07-15-23-00
  testdatabase-21-07-15-10-00
  testdatabase-21-07-15-23-00
  </code></pre>
  
  <p>What I am trying to do is that whenever it reaches the code marked with <code>*!*</code>, it goes back to <code>foreach</code> loop in the top every time. That marked code is not getting executed.</p>
  
  <p>Can someone please tell me the solution?</p>