Title: Accessing global functions from inside ForEach-Object -Parallel · Issue #12313 · PowerShell/PowerShell · GitHub
Open Graph Title: Accessing global functions from inside ForEach-Object -Parallel · Issue #12313 · PowerShell/PowerShell
X Title: Accessing global functions from inside ForEach-Object -Parallel · Issue #12313 · PowerShell/PowerShell
Description: 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. Libr...
Open Graph Description: 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 L...
X Description: 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 L...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/12313
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Accessing global functions from inside ForEach-Object -Parallel","articleBody":"Hello,\r\nI 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.\r\n\r\n# Steps to reproduce\r\n\r\n```powershell\r\nusing module .\\logger.ps1\r\n\r\nclass SPOLibrary {\r\n \r\n [void]ExportItems (\r\n [string]$OutputFileName\r\n ) {\r\n\r\n try {\r\n\r\n # MAIN: process loaded queue \r\n $this.Process( $OutputFileName) \r\n \r\n }\r\n finally {\r\n\r\n\r\n \r\n }\r\n\r\n \r\n }\r\n\r\n [void]Process (\r\n [string]$OutputFileName\r\n ){\r\n\r\n \r\n [int]$_batchSize = 20\r\n \r\n\r\n 1..$_batchSize | ForEach-Object -Parallel {\r\n\r\n # NOW here is the global function that is not visible to this block\r\n Log \"text\"\r\n }\r\n\r\n }\r\n```\r\n\r\n# Expected behavior\r\n\r\n```\r\nglobal functions should be visible within script block\r\n\r\n```\r\n\r\n# Actual behavior\r\n\r\n```\r\nfunction is not visible\r\n\r\n```\r\n\r\n# Environment data\r\n\r\n\u003c!-- provide the output of $PSVersionTable -->\r\n\r\n```\r\nName Value\r\n---- -----\r\nPSVersion 7.0.0\r\nPSEdition Core\r\nGitCommitId 7.0.0\r\nOS Microsoft Windows 10.0.19603\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n","author":{"url":"https://github.com/devmanlab","@type":"Person","name":"devmanlab"},"datePublished":"2020-04-14T19:55:20Z","url":"https://github.com/PowerShell/PowerShell/issues/12313"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a131de30-5fe0-5d7a-bc72-21cc1adbcb04 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B86C:3E7A4F:34D2BF:4AA1B2:6AFDE733 |
| html-safe-nonce | 250ba783805bab754623256cb0b501fd03271c6fb889d2e1ad3e7ff7ac97f0a2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCODZDOjNFN0E0RjozNEQyQkY6NEFBMUIyOjZBRkRFNzMzIiwidmlzaXRvcl9pZCI6IjUwNTQzNDI3ODczMTUzOTQzNTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6ddff54f9ab672acfbed2ed06e496dee37375b5ae2f9f65ed488fb49613b170c |
| hovercard-subject-tag | issue:599820868 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/12313/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7e7c4f1802415631c4b027fe55acd027bd4342fa172b222ab3880505778d67d9/PowerShell/PowerShell/issues/12313 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7e7c4f1802415631c4b027fe55acd027bd4342fa172b222ab3880505778d67d9/PowerShell/PowerShell/issues/12313 |
| og:image:alt | 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 L... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | devmanlab |
| hostname | github.com |
| expected-hostname | github.com |
| None | 91ef1a291a064ac31ac459ab3f75261dbdd924c41ea5bd027e591c5b46cc9ce7 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d62bc98ce2346f4006e4a2810e9e22f37e7e6422 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width