title: Powershell script to retry move-item until success is not working
body: <p>I wrote the following loop to sleep 5 seconds if the attempt to rename the file fails, however, when the event log reports failure ($? is false) it isn't retrying, it just moves on to the next block of code:</p>
  
  <pre><code>DO
  {
      Move-Item -Path $old_log_name -Destination $new_log_name
      if($?){
          Write-EventLog -LogName Application -Source my_application -EventId 4 -Message "Successfully moved $old_log_name to $new_log_name"
      }
      else{
          Write-EventLog -LogName Application -Source my_application -EventId 4 -Message "Failed to move $old_log_name to $new_log_name : $LastExitCode sleeping 5 secconds"
          Start-Sleep -Seconds 5
      }
  } Until ($?)
  </code></pre>
  
  <p>Am I missing something here???  Also on the same topic, $LastExitCode is showing up as blank.  Any ideas why?</p>