title: Powershell loop only if condition is true
body: <p>Very new to coding in general, so I fear I am missing something completely obvious. I want my program to check for a file. If it is there, just continue the code. If it has not arrived, continue cheking for a given amount of time, or untill the file shows up. My loop works on its own, so when i only select the do-part in Powershell ISE, it works. But when i try running it inside the if statement, nothing happens. The loops doesnt begin.</p>
  
  <pre><code>$exists= Test-Path $resultFile 
  $a = 1 
  
  if ($exists -eq "False")
  { 
  do 
      {
      $a++
      log "Now `$a is $a "
      start-sleep -s ($a)
      $exists= Test-Path $resultFile 
      write-host "exists = $exists"                
      }
      while (($a -le 5) -and ($exists -ne "True"))       
   }
  </code></pre>