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

-InitializationScript does not support $using: variable references #45

Open
mklement0 opened this issue Sep 26, 2019 · 1 comment
Open

Comments

@mklement0
Copy link

To next best thing to having a -WorkingDirectory parameter (hopefully soon, see #44) is to try something like the following:

Start-ThreadJob -InitializationScript { Set-Location $using:PWD } { $PWD } |
  Receive-Job -Wait -AutoRemoveJo

However, this currently fails:

A Using variable cannot be retrieved. 
A Using variable can be used only with Invoke-Command, Start-Job, or InlineScript
in the script workflow. 
When it is used with Invoke-Command, the Using variable is valid only if the script block is invoked on a remote computer.

This appears to be the same bug as in PowerShell itself (not sure how code is shared): PowerShell/PowerShell#4530

As an aside re the error message:

  • Since Start-ThreadJob now ships with PowerShell, the error message should probably mention it as well.
  • The reference to workflows should probably be removed.
@kborowinski
Copy link

@PaulHigin This is rather important IMHO, any timeframe on fixing this? Also which is the correct repo to create issues now. This one or the that?

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

2 participants