title: PowerShell Remove-Item not waiting
body: <p>If have this piece of code</p>
  
  <pre><code>if(Test-Path -Path $OUT) 
  { 
      Remove-Item $OUT -Recurse 
  }
  New-Item -ItemType directory -Path $OUT
  </code></pre>
  
  <p>Sometimes it works, but sometimes the New-Item line produces a <em>PermissionDenied  ItemExistsUnauthorizedAccessError</em> error. Which, I assume, means that the previous Remove-Item was not completely performed yet and the folder cannot be created because it still exists.</p>
  
  <p>If I insert a sleep there</p>
  
  <pre><code>if(Test-Path -Path $OUT) 
  { 
      Remove-Item $OUT -Recurse 
      Start-Sleep -s 1
  }
  New-Item -ItemType directory -Path $OUT
  </code></pre>
  
  <p>then it works always. 
  How can I force Remove-Item to ensure that the folder is really removed?
  Or maybe I miss something else?</p>