I developed some custom cmdlets 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).
The main script starts a new job with Start-Job
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.
But after around 15-20 seconds the job just gets terminated with the following error message:
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
I can't find any information on how to handle such an error. I just don't know what is the problem here.
Do I have to add further functionalities to my custom cmdlets so they can be handled in a job?
Here are the scripts.
Main:
[object]$credentials = Get-Credential -UserName "domain\user" -Message "Log in"
$job = start-job -FilePath "C:\ImportItems.ps1" -Name ImportItems -ArgumentList $credentials
$job | Wait-Job
ImportItems:
[CmdletBinding()]
Param(
[object]$credentials
)
Import-Module C:\Migration\MigrationShell.dll
Import-Items -Credential $credentials
Import-Items
. – Tricornered[Console]::InputEncoding
? – Alleenallegation