PaulHigin / PSThreadJob

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

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

Open mklement0 opened 5 years ago

mklement0 commented 5 years ago

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): https://github.com/PowerShell/PowerShell/issues/4530

As an aside re the error message:

kborowinski commented 1 year ago

@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?