This does not return anything:
$x = "C:\temp" Start-Job -ScriptBlock {get-childItem -path $x} | Wait-Job | Receive-job
But providing a path parameter without a variable, for example ...
Start-Job -ScriptBlock {get-childItem -path C:\temp} | Wait-Job | Receive-job
... returns the contents of this temporary durrr.txt folder in this case. This applies to Windows Server 2008R2 SP1 with Powershell $ host.version output as follows:
Major Minor Build Revision ----- ----- ----- -------- 3 0 -1 -1
Suspecting Powershell v3, I tried updating the Windows 7 desktop with Service Pack 1 (SP2) from version 2 to version 3, but failed to recreate the problem. On this updated desktop, the output of $ host.version now matches the above.
What's happening?
EDIT / What is happening?
Overloaded task seems equivalent
Start-Job -ScriptBlock {get-childItem -path $null} | Wait-Job | Receive-job
So, gci returned the results for the current directory of the current job, the Documents folder, which turned out to be empty.
source share