PaulHigin / PSThreadJob

A PowerShell module for running concurrent jobs based on threads rather than processes
MIT License
180 stars 18 forks source link

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

Open Stevie-O opened 2 years ago

Stevie-O commented 2 years ago

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