Product, version and build: Powershell Studio 2021
Operating system: Windows 10 64 Bit
PowerShell version(s): PowerShell 7.1
Hallo,
i have a problem with the new PowerShell7 Feature "ForEach-Object -parallel !!!!
I tryed a lot of thinks, but nothing workted for me, I hope you can help.
I try this code:
$button1_Click={
1...5 | ForEach-Object -Parallel { start-sleep 5 } -ThrottleLimit 5
$textbox1.Text = "Finish"
}
In PowerShellStudio 2021 i select V7 - 64 Bit and hit run. Everything good, no Problem.
So I hit "Package" and "Build". (In settings i choose Powershell 7.1.0 and Windows Forms)
(STA is OFF)
Than I hit the EXE File. The Programm Starts, but I never come to the point of "$textbox1.text".
In the Taskmanager I can see that 5 new Processes are started called "Windows Powershell", but nothinh happen.
So my script and the processes run forever.
I hope someone can help me.
ForEach-Object -parallel
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: ForEach-Object -parallel
Thanks for reporting the problem, we have been able to reproduce it and have filed a bug report with the development team.
We are investigating this and will update you as soon as we have more information
We are investigating this and will update you as soon as we have more information
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: ForEach-Object -parallel
Can you please confirm that when executed from a PowerShell 7.1 package you see 5 processes titled "Windows PowerShell" and not "pwsh" on your machine?
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- SchuleDigital_HG
- Posts: 5
- Last visit: Tue Nov 28, 2023 6:48 am
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: ForEach-Object -parallel
I have looked at the code for PowerShell 7 in that regard. Basically if a script is not running under pwsh.exe, they do not attempt to find it where it is supposed to be, that just default to Windows PowerShell, which obviously will not work in this case. So it seems at the moment it seems you can only use this feature when running a script, but not when packaged.
It is possible that we can do something from the hosting side of things, but obviously we would prefer if Microsoft would fix that.
It is possible that we can do something from the hosting side of things, but obviously we would prefer if Microsoft would fix that.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.