Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$PSScriptRoot is not populated for scripts run in a ThreadJob #64

Open
jazzdelightsme opened this issue Sep 27, 2020 · 0 comments
Open

Comments

@jazzdelightsme
Copy link
Contributor

The problem is pretty straightforward: I have a script that uses $PSScriptRoot, but when I ran the script in a ThreadJob, it malfunctioned, because $PSScriptRoot evaluated to an empty string.

Repro steps:

echo 'Write-Host "PSScriptRoot is: $PSScriptRoot"' > ReproThreadJobHasNoScriptRoot.ps1
start-threadjob -FilePath .\ReproThreadJobHasNoScriptRoot.ps1 | Receive-Job -Wait

Expected result:

PSScriptRoot is: <it should print out the current directory>

Actual result:

PSScriptRoot is:

Environment

Name                           Value
----                           -----
PSVersion                      7.1.0-preview.7
PSEdition                      Core
GitCommitId                    7.1.0-preview.7
OS                             Microsoft Windows 10.0.20222
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant