René's URL Explorer Experiment


Title: Passing `$null` to `[Environment]::SetEnvironmentVariable` sets environment variable to empty string `''` (7.5 RC1) · Issue #24637 · PowerShell/PowerShell · GitHub

Open Graph Title: Passing `$null` to `[Environment]::SetEnvironmentVariable` sets environment variable to empty string `''` (7.5 RC1) · Issue #24637 · PowerShell/PowerShell

X Title: Passing `$null` to `[Environment]::SetEnvironmentVariable` sets environment variable to empty string `''` (7.5 RC1) · Issue #24637 · PowerShell/PowerShell

Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...

Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...

X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...

Opengraph URL: https://github.com/PowerShell/PowerShell/issues/24637

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Passing `$null` to `[Environment]::SetEnvironmentVariable` sets environment variable to empty string `''` (7.5 RC1)","articleBody":"### Prerequisites\r\n\r\n- [X] Write a descriptive title.\r\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- [X] Search the existing issues.\r\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\r\n\r\n### Steps to reproduce\r\n\r\nIn .NET 9, a [breaking change](https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/9.0/empty-env-variable) introduced empty string support to environment variables. As of that change, the only way to remove an environment variable is to set it to `null` via `Environment.SetEnvironmentVariable()`. I've confirmed this behavior in .NET 9 with C#.\r\n\r\nPR #24133 introduced .NET 9, and the above breaking change, into PowerShell v7.5.0-preview.4.\r\n\r\nHowever, setting an environment variable to `$null` in `[Environment]::SetEnvironmentVariable()` now sets the environment variable to an empty string, instead of the expected behavior of unsetting the environment variable. Notably, setting the variable to null via the ENV provider works as expected.\r\n\r\nThe below tests explain the expected behavior, but `Environment Variable.System.Environment.Should unset environment variables with null` fails because `[Environment]::GetEnvironmentVariable()` yields an empty string `''` instead of `$null`.\r\n\r\n```pwsh\r\nDescribe 'Environment Variable' {\r\n\r\n    Context 'System.Environment' {\r\n        It 'Should unset environment variables with null' {\r\n            [System.Environment]::SetEnvironmentVariable('TEST_DOTNETAPI_NULL', $null)\r\n            [System.Environment]::GetEnvironmentVariable('TEST_DOTNETAPI_NULL') | Should -Be $null\r\n        }\r\n\r\n        # See breaking change in .NET 9:\r\n        # https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/9.0/empty-env-variable\r\n        It 'Should set environment variables with empty string' -Skip:([Environment]::Version.Major -lt 9) {\r\n            [System.Environment]::SetEnvironmentVariable('TEST_DOTNETAPI_EMPTY', '')\r\n            [System.Environment]::GetEnvironmentVariable('TEST_DOTNETAPI_EMPTY') | Should -Be ''\r\n        }\r\n    }\r\n\r\n    Context 'ENV Drive' {\r\n        It 'Should unset environment variables with null' {\r\n            $ENV:TEST_ENV_NULL = $null\r\n            $ENV:TEST_ENV_NULL | Should -Be $null\r\n        }\r\n\r\n        # See breaking change in .NET 9:\r\n        # https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/9.0/empty-env-variable\r\n        It 'Should set environment variables with empty string' -Skip:([Environment]::Version.Major -lt 9) {\r\n            $ENV:TEST_ENV_EMPTY = ''\r\n            $ENV:TEST_ENV_EMPTY | Should -Be ''\r\n        }\r\n    }\r\n}\r\n```\r\n\r\n### Expected behavior\r\n\r\n```console\r\nAll four tests pass\r\n```\r\n\r\n\r\n### Actual behavior\r\n\r\n```console\r\n> Invoke-Pester .\\EnvironmentVariable.Tests.ps1\r\n\r\nStarting discovery in 1 files.\r\nDiscovery found 4 tests in 7ms.\r\nRunning tests.\r\n[-] Environment Variable.System.Environment.Should unset environment variables with null 4ms (3ms|0ms)\r\n Expected $null, but got \u003cempty>.\r\n at [System.Environment]::GetEnvironmentVariable('TEST_DOTNETAPI_NULL') | Should -Be $null, C:\\EnvironmentVariableTest\\EnvironmentVariable.Tests.ps1:6\r\n at \u003cScriptBlock>, C:\\EnvironmentVariableTest\\EnvironmentVariable.Tests.ps1:6\r\nTests completed in 60ms\r\nTests Passed: 3, Failed: 1, Skipped: 0, Inconclusive: 0, NotRun: 0\r\n```\r\n\r\n\r\n### Error details\r\n\r\n_No response_\r\n\r\n### Environment data\r\n\r\n```powershell\r\nName                           Value\r\n----                           -----\r\nPSVersion                      7.5.0-rc.1\r\nPSEdition                      Core\r\nGitCommitId                    7.5.0-rc.1\r\nOS                             Microsoft Windows 10.0.22631\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\r\n\r\n### Visuals\r\n\r\n_No response_","author":{"url":"https://github.com/pjking07","@type":"Person","name":"pjking07"},"datePublished":"2024-12-03T18:30:07Z","url":"https://github.com/PowerShell/PowerShell/issues/24637"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:068676b6-8b6c-3d88-119b-641e765060c8
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA422:1ABC75:22B079C:306115B:6AFD35B9
html-safe-nonce60403535028862c065fbb824f652740ae5d682c1b4edb037234b9066d82e1116
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDIyOjFBQkM3NToyMkIwNzlDOjMwNjExNUI6NkFGRDM1QjkiLCJ2aXNpdG9yX2lkIjoiMzE2MTcyODEzMzY1NzA4MTI3NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac013064e016a26bb6c0d128cdab7b8906e5bd4c8d3b456e474864c1bb3a946fdc
hovercard-subject-tagissue:2715733316
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/24637/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f3b27714078f9b049571b67efcd11da45d083d379a43448d21065982f83b6d4a/PowerShell/PowerShell/issues/24637
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f3b27714078f9b049571b67efcd11da45d083d379a43448d21065982f83b6d4a/PowerShell/PowerShell/issues/24637
og:image:altPrerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepjking07
hostnamegithub.com
expected-hostnamegithub.com
None065128366c233a9d57ff68ab6c96e25b99dd1b0ab70d23b70873d3dd6b5e4f19
turbo-cache-controlno-preview
go-importgithub.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id49609581
octolytics-dimension-repository_nwoPowerShell/PowerShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id49609581
octolytics-dimension-repository_network_root_nwoPowerShell/PowerShell
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release941021edf0c2ec58298f4a2c8f27ae507d129c92
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/PowerShell/PowerShell/issues/24637#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F24637
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F24637
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PowerShell%2FPowerShell
Reloadhttps://github.com/PowerShell/PowerShell/issues/24637
Reloadhttps://github.com/PowerShell/PowerShell/issues/24637
Reloadhttps://github.com/PowerShell/PowerShell/issues/24637
PowerShellhttps://github.com/PowerShell
PowerShellhttps://github.com/PowerShell/PowerShell
Codehttps://github.com/PowerShell/PowerShell
Issues1.3k (1.3k)https://github.com/PowerShell/PowerShell/issues
Pull requests364 (364)https://github.com/PowerShell/PowerShell/pulls
Discussionshttps://github.com/PowerShell/PowerShell/discussions
Actionshttps://github.com/PowerShell/PowerShell/actions
Projectshttps://github.com/PowerShell/PowerShell/projects
Security and quality3 (3)https://github.com/PowerShell/PowerShell/security
Insightshttps://github.com/PowerShell/PowerShell/insights
https://github.com/PowerShell/PowerShell
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/24637
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/24637
Passing $null to [Environment]::SetEnvironmentVariable sets environment variable to empty string '' (7.5 RC1)https://github.com/PowerShell/PowerShell/issues/24637#top
Needs-TriageThe issue is new and needs to be triaged by a work group.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Needs-Triage%22
Resolution-DuplicateThe issue is a duplicate.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-Duplicate%22
https://github.com/pjking07
PJ King (pjking07)https://github.com/pjking07
on Dec 3, 2024https://github.com/PowerShell/PowerShell/issues/24637#issue-2715733316
latest released versionhttps://github.com/PowerShell/PowerShell/releases
FAQhttps://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md
Differences between Windows PowerShell 5.1 and PowerShellhttps://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell
breaking changehttps://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/9.0/empty-env-variable
#24133https://github.com/PowerShell/PowerShell/pull/24133
PJ King (pjking07)https://github.com/pjking07
Needs-TriageThe issue is new and needs to be triaged by a work group.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Needs-Triage%22
on Dec 3, 2024https://github.com/PowerShell/PowerShell/issues/24637#event-15514473957
PJ King (pjking07)https://github.com/pjking07
on Dec 3, 2024https://github.com/PowerShell/PowerShell/issues/24637#event-15514490631
https://github.com/pjking07
PJ King (pjking07)https://github.com/pjking07
on Dec 3, 2024https://github.com/PowerShell/PowerShell/issues/24637#issuecomment-2515478013
https://github.com/rhubarb-geek-nz
rhubarb-geek-nzhttps://github.com/rhubarb-geek-nz
on Dec 3, 2024https://github.com/PowerShell/PowerShell/issues/24637#issuecomment-2515596071
#24605https://github.com/PowerShell/PowerShell/discussions/24605
https://camo.githubusercontent.com/e9f766d99f7db1359eb00f2e7f9ae07c9929be0e5fbb006c9e2831d0fb378e09/68747470733a2f2f6f70656e67726170682e6769746875626173736574732e636f6d2f643336316664383066333764333032663430303962653063663165636439633130363539616365346635383263366661393765343365333336323763643734632f506f7765725368656c6c2f506f7765725368656c6c2f64697363757373696f6e732f3234363035
https://camo.githubusercontent.com/7e41d4698b37a89b2a8c06057583a5f48ce614b0fb7e2b93d27a2ec01c8f024b/68747470733a2f2f6769746875622e6769746875626173736574732e636f6d2f66617669636f6e732f66617669636f6e2e737667
7.5-rc1 SetEnvironmentVariable breaking change, feature or bug? · PowerShell PowerShell · Discussion #24605https://github.com/PowerShell/PowerShell/discussions/24605
https://github.com/kilasuit
Ryan Yates (kilasuit)https://github.com/kilasuit
on Dec 3, 2024https://github.com/PowerShell/PowerShell/issues/24637#issuecomment-2515600276
Issue 21186https://github.com/PowerShell/PowerShell/issues/21186
in this commenthttps://github.com/PowerShell/PowerShell/issues/21186#issuecomment-2270067750
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on Dec 3, 2024https://github.com/PowerShell/PowerShell/issues/24637#issuecomment-2515721848
Ryan Yates (@kilasuit)https://github.com/kilasuit
#21186 (comment)https://github.com/PowerShell/PowerShell/issues/21186#issuecomment-2187252118
Ilya (iSazonov)https://github.com/iSazonov
Resolution-DuplicateThe issue is a duplicate.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-Duplicate%22
on Dec 4, 2024https://github.com/PowerShell/PowerShell/issues/24637#event-15518652456
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Dec 5, 2024https://github.com/PowerShell/PowerShell/issues/24637#issuecomment-2519028966
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
completedhttps://github.com/PowerShell/PowerShell/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Dec 5, 2024https://github.com/PowerShell/PowerShell/issues/24637#event-15535265436
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Dec 5, 2024https://github.com/PowerShell/PowerShell/issues/24637#issuecomment-2519029098
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
PJ King (@pjking07)https://github.com/pjking07
https://aka.ms/PSRepoFeedbackhttps://aka.ms/PSRepoFeedback
Microsoft Formshttps://aka.ms/PSRepoFeedback
Daniel Han (danielhanchen)https://github.com/danielhanchen
on Apr 16, 2026https://github.com/PowerShell/PowerShell/issues/24637#event-24563538113
Guard shim PATH entry on existence, use NullString for broadcast deletehttps://github.com/Etherll/unsloth/commit/14a0fdf9cde300e38d093f3163e6d4b017ec89af
14a0fdfhttps://github.com/Etherll/unsloth/commit/14a0fdf9cde300e38d093f3163e6d4b017ec89af
fix: use direct registry API for PATH writes instead of SetEnvironmen…https://github.com/unslothai/unsloth/commit/ec32ce2e822289a192b92f877ef4f7b5d1850434
ec32ce2https://github.com/unslothai/unsloth/commit/ec32ce2e822289a192b92f877ef4f7b5d1850434
Sign up for freehttps://github.com/signup?return_to=https://github.com/PowerShell/PowerShell/issues/24637
Sign in to commenthttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/24637
Needs-TriageThe issue is new and needs to be triaged by a work group.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Needs-Triage%22
Resolution-DuplicateThe issue is a duplicate.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-Duplicate%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.