When I execute a simple statement locally
$path = 'C:\Windows\System32\WindowsPowerShell\v1.0'
gci $path
I see the response immediately. But when I execute it as job on my local machine
$start = get-date
$path = 'C:\Windows\System32\WindowsPowerShell\v1.0'
$cmd = [scriptblock]::Create("gci $path")
$jnr1 = Invoke-Command -computer localhost -ScriptBlock $cmd -asJob
Wait-Job $jnr1
Receive-job $jnr1
$end = Get-date
($end - $start).totalseconds
I have to wait 55 seconds. From my unix experience a decade ago. I would expect background jobs to run nearly as fast as foreground jobs.
Are there ways to speed up the execution of PowerShell background jobs?