title: Start-Job including custom cmdlet terminates with strange error
body: <p>I developed some custom <a href="https://msdn.microsoft.com/en-us/library/system.management.automation.pscmdlet(v=vs.85).aspx" rel="nofollow">cmdlets</a> that serve for different importing tasks to a SharePoint system. Currently all those cmdlets are being run in a serial kind in a single PowerShell script. I want to change this so that each cmdlet gets executed in a separate task (job).</p>
  
  <p>The main script starts a new job with <code>Start-Job</code> relating to a separate script that contains the call to the cmdlet. The script starts and executes the cmdlet. I also debugged the code of the cmdlet that gets executed. So far so fine.</p>
  
  <p>But after around 15-20 seconds the job just gets terminated with the following error message:</p>
  
  <pre class="lang-none prettyprint-override"><code>There is an error processing data from the background process. Error reported:
  Cannot process an element with node type "Text". Only Element and EndElement
  node types are supported..
      + CategoryInfo          : OperationStopped: (localhost:String) [], PSRemotingTransportException
      + FullyQualifiedErrorId : JobFailure
      + PSComputerName        : localhost
  </code></pre>
  
  <p>I can't find any information on how to handle such an error. I just don't know what is the problem here.</p>
  
  <p>Do I have to add further functionalities to my custom cmdlets so they can be handled in a job?</p>
  
  <p>Here are the scripts.</p>
  
  <p>Main:</p>
  
  <pre><code>[object]$credentials = Get-Credential -UserName "domain\user" -Message "Log in"
  
  $job = start-job -FilePath "C:\ImportItems.ps1" -Name ImportItems -ArgumentList $credentials
  $job | Wait-Job
  </code></pre>
  
  <p>ImportItems:</p>
  
  <pre><code>[CmdletBinding()]
  Param(
    [object]$credentials
  )
  
  Import-Module C:\Migration\MigrationShell.dll
  Import-Items -Credential $credentials
  </code></pre>