Title: [ThreadJob] [FeatureRequest] Add -ParameterList argument to allow "splatting" parameters to be passed to the threadjob · Issue #75 · PowerShell/Modules · GitHub
Open Graph Title: [ThreadJob] [FeatureRequest] Add -ParameterList argument to allow "splatting" parameters to be passed to the threadjob · Issue #75 · PowerShell/Modules
X Title: [ThreadJob] [FeatureRequest] Add -ParameterList argument to allow "splatting" parameters to be passed to the threadjob · Issue #75 · PowerShell/Modules
Description: Paul Higinbotham (@PaulHigin) This issue was moved from PaulHigin/PSThreadJob#59 Currently there's no way to pass parameters to a threadjob scriptblock, you can pass arguments but they have to be processed positionally (or use inputobjec...
Open Graph Description: Paul Higinbotham (@PaulHigin) This issue was moved from PaulHigin/PSThreadJob#59 Currently there's no way to pass parameters to a threadjob scriptblock, you can pass arguments but they have to be p...
X Description: Paul Higinbotham (@PaulHigin) This issue was moved from PaulHigin/PSThreadJob#59 Currently there's no way to pass parameters to a threadjob scriptblock, you can pass arguments but they have to ...
Opengraph URL: https://github.com/PowerShell/Modules/issues/75
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[ThreadJob] [FeatureRequest] Add -ParameterList argument to allow \"splatting\" parameters to be passed to the threadjob","articleBody":"@PaulHigin This issue was moved from https://github.com/PaulHigin/PSThreadJob/issues/59\r\n\r\nCurrently there's no way to pass parameters to a threadjob scriptblock, you can pass arguments but they have to be processed positionally (or use inputobject hashtable or a hashtable as the argument) which is not ideal because scriptblocks cannot use the `param` block to validate and assign the input.\r\n\r\nI recommend adding a `ParameterList` argument that would take a hashtable in the same format used for splatting, and call `_ps.AddParameters` for that hashtable right after this code:\r\n\r\nhttps://github.com/PaulHigin/PSThreadJob/blob/6f72128a9377e2c63667f69bff6dc66e85d2f5ae/PSThreadJob/PSThreadJob.cs#L1036-L1042\r\n\r\nAlternatively ArgumentList could accept a hashtable or parameterset, but this may interfere with activities that actually want to pass those specific types, hence the recommended separate Parameter.\r\n\r\nI'm willing to attempt a PR if there is interest.\r\n\r\n# Workarounds\r\n\r\n### Args Hashtable Parsing\r\nPut as first line of script rather than a param block, however doesn't allow any sort of validation within the parameters themselves\r\n```powershell\r\n if ($args[0] -is [HashTable]) {\r\n $args.keys.foreach{\r\n Set-Variable -Name $PSItem -Value $args[$PSItem]\r\n }\r\n }\r\n```\r\n\r\n### Positional Params\r\nAdd [Parameter(Position=x)] to each matching arg parameter and pass the args as an array rather than a hashtable (Position can also be implicit). Allows the scriptblock to still be used as a cmdlet (for testing, etc.) but makes the actual threadjob run less structured (since you have to get the parameter order exactly right and you have to make sure optional parameters are towards the end)\r\n\r\n```powershell\r\n$myargs = @(\r\n 'test1'\r\n 'test2'\r\n)\r\n\r\nstart-threadjob -argumentlist $myargs {\r\n param(\r\n [Parameter(Position=0)]$test1,\r\n [Parameter(Position=1)]$test2\r\n )\r\n \"Test1: $test1\"\r\n \"Test2: $test2\"\r\n}\r\n```","author":{"url":"https://github.com/JustinGrote","@type":"Person","name":"JustinGrote"},"datePublished":"2020-04-29T14:49:42Z","url":"https://github.com/PowerShell/Modules/issues/75"}
| 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:c7810f2b-7ec5-f33a-737f-a91c39d9f5bc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D344:34B842:2B70A6:39BB6F:6AFD35D1 |
| html-safe-nonce | 685fc903c6b849cf99d806d85a82b6e2c5d8b30b65cfceaa041c71da22cbf69a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzQ0OjM0Qjg0MjoyQjcwQTY6MzlCQjZGOjZBRkQzNUQxIiwidmlzaXRvcl9pZCI6IjI5MzAxNDIyNjAxMDYxODAwNDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 998d2b1f8e6d0345d7bc0586386585a95472f0994635e14a637a8d397d552156 |
| hovercard-subject-tag | issue:609119191 |
| 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/Modules/75/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cdf54829ed8c9a14cded58331018dff4d3abdfc48a168e3c1fa1078cf060a4de/PowerShell/Modules/issues/75 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cdf54829ed8c9a14cded58331018dff4d3abdfc48a168e3c1fa1078cf060a4de/PowerShell/Modules/issues/75 |
| og:image:alt | Paul Higinbotham (@PaulHigin) This issue was moved from PaulHigin/PSThreadJob#59 Currently there's no way to pass parameters to a threadjob scriptblock, you can pass arguments but they have to be p... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JustinGrote |
| hostname | github.com |
| expected-hostname | github.com |
| None | 065128366c233a9d57ff68ab6c96e25b99dd1b0ab70d23b70873d3dd6b5e4f19 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/Modules git https://github.com/PowerShell/Modules.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 197814114 |
| octolytics-dimension-repository_nwo | PowerShell/Modules |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 197814114 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/Modules |
| 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 | 941021edf0c2ec58298f4a2c8f27ae507d129c92 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width