We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
On a machine in a distant land, exists a script named thing.ps1 with content:
thing.ps1
$script:foo = 'abc' function f { return $script:foo }
If I attempt to run f from my interactive session, I see "abc" like I'd expect:
f
If I try to run it via Start-RSJob, I see nothing...
Start-RSJob
Start-RSJob { f } -Name 1 -FunctionFilesToImport $(ls .\thing.ps1).fullname Receive-RSJob -name 1
The value $script:foo in the script passed to Start-RSJob returns as $null.
$script:foo
Can you not use variables in the script scope?
The text was updated successfully, but these errors were encountered:
for function f variable $script:foo - like a global variable. RSJob can not import any variables that used inside functions if it not local.
Btw, it is a bad practice.
as a workaround you can use truly global variables, function parameters or modules (variable defined in a module will be imported with module
global
parameters
modules
Sorry, something went wrong.
No branches or pull requests
On a machine in a distant land, exists a script named
thing.ps1
with content:If I attempt to run
f
from my interactive session, I see "abc" like I'd expect:If I try to run it via
Start-RSJob
, I see nothing...The value
$script:foo
in the script passed toStart-RSJob
returns as $null.Can you not use variables in the script scope?
The text was updated successfully, but these errors were encountered: