ForEach -Parallel $pwd
See original GitHub issueSteps to reproduce
Go to some directory other then ~
. Run 1 | % -Parallel {$pwd}
Expected behavior
Output should be the same as just $pwd
Actual behavior
Output is always the ~
directory.
Environment data
Name Value
---- -----
PSVersion 7.0.0-preview.3
PSEdition Core
GitCommitId 7.0.0-preview.3
OS Darwin 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:13 (7 by maintainers)
Top Results From Across the Web
about Foreach-Parallel - PowerShell
The Parallel parameter of the ForEach keyword runs the commands in a ForEach script block once for each item in a specified collection....
Read more >Get a thread id inside parallel.ForEach loop
Is there a way to find the thread id inside Parallel.ForEach in above scenario? Note: I could have used Parallel.For in the example...
Read more >Easy way to do foreach -parallel : r/PowerShell
Im writing a script that will execute a bunch of commands remotely on a list of servers. So I was planning on using...
Read more >Understanding the Differences Between PowerShell's Parallel ...
we'll explore the behavior of PowerShell's Foreach -Object with Parallelism. We'll dive into the differences between using Parallel ...
Read more >How do I use a parallel.foreach?
I am trying to use a parallel.foreach. However, I noticed that when I set a count to see the iteration, I noticed that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@PaulHigin
Making
Start-ThreadJob
followStart-Job
’s example generally makes sense, but note that:(a) it already behaves differently from
Start-Job
(b) even if that were to be fixed,
Start-Job
’s behavior is unfortunate© Ideally, we’d have a consistent experience across all job/thread-related features, meaning:
&
to start a jobForEach-Object -Parallel
The question now is:
Can we consider
Start-Job
’s default-to-$HOME
behavior a bug / something worth fixing as a Bucket 3: Unlikely Grey Area change, as argued by @iSazonov above?If so, we can achieve the desired consistency, by making all features default to the caller’s current location.
I’m certainly personally in favor of that, but I haven’t looked into how likely it is that existing
Start-Job
code relies on$HOME
to be the default directory.I have submitted a PR for the fix for ForEach-Object -Parallel (#10672 ).