I have a recursive function that is executed around 750~ times - iterating over XML files and processing. The code is running using Start-Job
Example below:
$job = Start-Job -ScriptBlock {
function Test-Function {
Param
(
$count
)
Write-Host "Count is: $count"
$count++
Test-Function -count $count
}
Test-Function -count 1
}
Output:
$job | Receive-Job
Count is: 224
Count is: 225
Count is: 226
Count is: 227
The script failed due to call depth overflow.
The depth overflow occurs at 227 consistently on my machine. If I remove Start-Job, I can reach 750~ (and further). I am using jobs for batch processing.
Is there a way to configure the depth overflow value when using Start-Job?
Is this a limitation of PowerShell Jobs?