title: Script block of Start-Job hang in Powershell?
body: <p>I have the following script. The created background job never finishes. (It finishes in a few seconds if I just run the scripts in the <code>-ScriptBlock { ... }</code>).</p>
  
  <p><strong>Edit:</strong><br>
  My machine is XP/sp3. This may be the reason of hang as Jon found out.</p>
  
  <pre><code>Start-Job -ScriptBlock {
      if ( (Get-PSSnapin -Name Sql* -ErrorAction SilentlyContinue) -eq $null )
      {
          Add-PSSnapin Sql*
      }
      Invoke-Sqlcmd -Query "select 1 a" -ServerInstance serverX -ErrorAction stop
  }
  </code></pre>
  
  <p><code>Receive-Job *</code> returns nothing and <code>Get-Job</code> always returns the following lines.</p>
  
  <pre><code>&gt; Get-Job
  
  Id              Name            State      HasMoreData     Location             Command                  
  --              ----            -----      -----------     --------             -------                  
  29              Job29           Running    True            localhost            ...                      
  </code></pre>