question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ForEach -Parallel $pwd

See original GitHub issue

Steps 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
mklement0commented, Oct 1, 2019

@PaulHigin

Making Start-ThreadJob follow Start-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:

  • Start-Job
  • Start-ThreadJob
  • postpositional & to start a job
  • ForEach-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.

1reaction
PaulHigincommented, Oct 1, 2019

I have submitted a PR for the fix for ForEach-Object -Parallel (#10672 ).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found