Title: Modifying AllScope variable in "global" SessionState affects module but not vice versa · Issue #6378 · PowerShell/PowerShell · GitHub
Open Graph Title: Modifying AllScope variable in "global" SessionState affects module but not vice versa · Issue #6378 · PowerShell/PowerShell
X Title: Modifying AllScope variable in "global" SessionState affects module but not vice versa · Issue #6378 · PowerShell/PowerShell
Description: This behavior is surprising to me. I'm not sure if it is as intended, as neither the documentation for ScopedItemOptions nor about_Scopes seem to contemplate the behavior of AllScope variables in the context of multiple SessionStates. St...
Open Graph Description: This behavior is surprising to me. I'm not sure if it is as intended, as neither the documentation for ScopedItemOptions nor about_Scopes seem to contemplate the behavior of AllScope variables in t...
X Description: This behavior is surprising to me. I'm not sure if it is as intended, as neither the documentation for ScopedItemOptions nor about_Scopes seem to contemplate the behavior of AllScope variables ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/6378
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Modifying AllScope variable in \"global\" SessionState affects module but not vice versa","articleBody":"This behavior is surprising to me. I'm not sure if it is as intended, as neither the documentation for [ScopedItemOptions](https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.scopeditemoptions?view=powershellsdk-1.1.0) nor [about_Scopes](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scopes?view=powershell-6) seem to contemplate the behavior of `AllScope` variables in the context of multiple SessionStates.\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\n```powershell\r\n$m = New-Module {}\r\nSet-Variable v -Value 'v.1' -Option AllScope\r\n\r\n& $m { $v }\r\n& $m { $v = 'v.2'; $v }\r\n$v\r\n& {\r\n $v = 'v.3'\r\n}\r\n$v\r\n& $m { $v }\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n\r\nI expected that \r\n\r\neither there really is only one `$v` and the output is\r\n```none\r\nv.1\r\nv.2\r\nv.2\r\nv.3\r\nv.3\r\n```\r\n\r\nor, there are two `$v` that are really unrelated and the output is\r\n\r\n```none\r\nv.1\r\nv.2\r\nv.1\r\nv.3\r\nv.2\r\n```\r\n\r\nActual behavior\r\n---------------\r\n\r\nThe actual behavior seems to be consistent with two `$v` that are sort-of related.\r\n```none\r\nv.1\r\nv.2\r\nv.1\r\nv.3\r\nv.3\r\n```\r\n\r\nEnvironment data\r\n----------------\r\n\r\n\u003c!-- provide the output of $PSVersionTable -->\r\n\r\n```powershell\r\n> $PSVersionTable\r\n\r\nName Value \r\n---- ----- \r\nPSVersion 6.0.0 \r\nPSEdition Core \r\nGitCommitId v6.0.0 \r\nOS Microsoft Windows 6.3.9600 \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/alx9r","@type":"Person","name":"alx9r"},"datePublished":"2018-03-13T17:27:00Z","url":"https://github.com/PowerShell/PowerShell/issues/6378"}
| 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:8cbf5168-ad59-7638-211d-88c79bb11de4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8330:AE565:28DC7:34A6D:6AFD07A1 |
| html-safe-nonce | b15462fccc9a816b0ab001dfcc26b56d1355f9c5b901292c3a2be5090c5d254e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzMwOkFFNTY1OjI4REM3OjM0QTZEOjZBRkQwN0ExIiwidmlzaXRvcl9pZCI6IjcxODU4ODg1Mzc1MjkzNTQxNDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7fd93d3156c8027393bb4a3287d094c2283b5c844641a555a7676f1d4a590c71 |
| hovercard-subject-tag | issue:304862046 |
| 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/6378/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9a07f387cebdae7ebcedf6b73d629687d40b9e7cdd2982aaa11e01c079eb23ec/PowerShell/PowerShell/issues/6378 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9a07f387cebdae7ebcedf6b73d629687d40b9e7cdd2982aaa11e01c079eb23ec/PowerShell/PowerShell/issues/6378 |
| og:image:alt | This behavior is surprising to me. I'm not sure if it is as intended, as neither the documentation for ScopedItemOptions nor about_Scopes seem to contemplate the behavior of AllScope variables in t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alx9r |
| hostname | github.com |
| expected-hostname | github.com |
| None | 8fd5a24ae29aa78df114eaaf1f9a839e8c3b7c0d27549e4f54678bb7cf3166d4 |
| 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 | dd0990b833f227378ab84f1d9519db1a04660550 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width