PSThreadJob icon indicating copy to clipboard operation
PSThreadJob copied to clipboard

Contrary to what the documentation says, the current directory (location) is not inherited by the job

Open Stevie-O opened this issue 4 years ago • 0 comments

Windows 10, Powershell 5.1.19041.1320

Import-Module ThreadJob -MinimumVersion 2.0.3

if (-not (test-path test-dir)) {
    mkdir test-dir | out-null
}
cd test-dir

Write-Host "Current directory: $(Get-Location)"

$job = Start-Job -ScriptBlock {  Write-Host "ThreadJob current directory: $(Get-Location)" }

Receive-Job $job -Wait -AutoRemoveJob

cd ..

Expected output:

Current directory: C:\Users\stevie-o\Documents\test-dir
ThreadJob current directory: C:\Users\stevie-o\Documents\test-dir

Actual output:

Current directory: C:\Users\stevie-o\Documents\test-dir
ThreadJob current directory: C:\Users\stevie-o\Documents

Stevie-O avatar Apr 22 '22 19:04 Stevie-O