title: Wait-Job doesn't wait
body: <p>Here is code </p>
  
  <pre><code>try{
      $SetupJob = invoke-command -ComputerName $j -Credential $credentials -ScriptBlock $sb -AsJob | Out-Null
  
  }
  catch [System.Exception]{
      continue
  }
  
  $SetupJob|Wait-Job
  
  
  $disable_command = "D:\PSTools\PsExec.exe $comp -u Administrator -p $str -accepteula powershell.exe c:\share\ps_disable.ps1"
  $CmdOutput = Invoke-Expression $disable_command 2&gt;&amp;1
  
  
  
  Remove-Item Z:\ps_*able.ps1
  Remove-Item Z:\setup.exe
  </code></pre>
  
  <p><code>$SetupJob</code> executes <code>setup.exe</code> on a remote_computer. After execution, it is supposed to be removed. But, I get the following</p>
  
  <pre><code>Remove-Item : Cannot remove item \\remote_computer\share\setup.exe: The process cannot access the file '\\remote_computer\share\setup.exe' because it is being used by another process.
  </code></pre>
  
  <p>How to fix?</p>