Accessing global functions in ForEach Parallel
Hello, I am processing large amount of Graph calls using powershell script block - 500K in my case. I want to process script blocks in batches. My ForEach-Object loop is defined inside class, say Library, in method, say ExportItems. Library.ExportItems call global function named Log([string]text). Method can successfully use it, however Parallel block cannot. While I will report it to product team, it would be nice to have documentation on how to access not just variables, defined outside parallel block, but also functions.
Thank you!
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 3965609b-1dd4-67db-af26-9f4a77fdabf7
- Version Independent ID: 7ba53b91-ed64-cc24-0cf0-a5dc3f3dc9d0
- Content: ForEach-Object (Microsoft.PowerShell.Core)
- Content Source: reference/7.0/Microsoft.PowerShell.Core/ForEach-Object.md
- Product: powershell
- GitHub Login: @SteveL-MSFT
- Microsoft Alias: slee
cc: @PaulHigin
I'll respond to the equivalent issue created in PowerShell github.
https://github.com/PowerShell/PowerShell/issues/12313