Title: Fix individual commands that do not respect an explicit `$false` value passed to a switch parameter · Issue #25242 · PowerShell/PowerShell · GitHub
Open Graph Title: Fix individual commands that do not respect an explicit `$false` value passed to a switch parameter · Issue #25242 · PowerShell/PowerShell
X Title: Fix individual commands that do not respect an explicit `$false` value passed to a switch parameter · Issue #25242 · 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/25242
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fix individual commands that do not respect an explicit `$false` value passed to a switch parameter","articleBody":"### Prerequisites\n\n- [x] Write a descriptive title.\n- [x] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\n- [x] Search the existing issues.\n- [x] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\n- [x] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\n\n### Steps to reproduce\n\n```powershell\n# The *presence* of the switch selects UseWindowsPowerShellParameterSet.\n# Irrespective of the switch *value*, CreateRunspacesForUseWindowsPowerShellParameterSet() is called.\n# This subverts reasonable user expectation. UseWindowsPowerShell was NOT requested, yet the command\n# ignores that request.\nNew-PSSession -UseWindowsPowerShell:$false\n\n# Likewise, this results in [datetime] output, despite it not being requested.\n$params = @{ Since = $false }\nGet-Uptime @params\n```\n\n### Context:\n\nThis is a continuation of the following issues:\n\n- https://github.com/PowerShell/PowerShell/issues/25015\n- https://github.com/PowerShell/PowerShell/issues/25027\n\nSummary:\n\n- The first issue discusses how `Get-Uptime -Since:$false` is not respected. That is, despite the explicit `$false` value, `Get-Uptime` behaves as if `-Since` or `-Since:$true` was specified.\n - This behavior was deemed erroneous and the issue was labelled `Up-for-grabs`.\n- The second issue is a proposal by @mklement0 for a systematic change that would implicitly fix the `Get-Uptime` issue *and* other commands that exhibit the same problem. \n - This proposal was rejected due to backwards compatibility concerns.\n- I encountered *at least* 10 commands shipped with PowerShell that exhibit the same problem when looking into the issue further. See [here](https://github.com/PowerShell/PowerShell/issues/25027#issuecomment-2661424666).\n- Per @iSazonov in [#25015](https://github.com/PowerShell/PowerShell/issues/25015#issuecomment-2661028506):\n\n\u003e Up-for-Grabs - we should fix all cmdlets in the repo if they implement a switch in wrong way.\n\n### List of commands to fix:\n\n- [x] `Get-Uptime -Since` #25015\n- [x] `New-Guid -Empty` #25276\n- [x] `Get-Random -Shuffle` #26456\n- [x] `Get-SecureRandom -Shuffle` #26460\n- [x] `Get-TimeZone -ListAvailable` #26462\n- [x] `New-PSSession -UseWindowsPowerShell` #26464\n- [x] `Split-Path -Qualifier`/`-NoQualifier`/`-Leaf`/`-IsAbsolute` (*not* `-Extension`/`-LeafBase`) #26470\n- [x] `Test-Connection -Repeat`/`-MtuSize`/`-Traceroute` #26475\n- [x] `Where-Object` (*all* non-common switch parameters) #26480\n- [ ] `ConvertTo-Csv -UseCulture:$false` #26513\n- [ ] `Export-Csv -UseCulture:$false` #26513\n- [ ] `ConvertFrom-Csv -UseCulture:$false`\n- [ ] `Import-Csv -UseCulture:$false`\n- [ ] `Get-Culture -ListAvailable:$false`\n- [ ] `Get-Location -Stack:$false`\n\n### Request\n\nFix each command listed above **_individually_**, so that explicitly passing a `$false` value to the specified switch parameter is respected.\n\n### Expected behavior\n\n`-Switch:$false` results in the same behavior as not passing `-Switch`.\n\n### Actual behavior\n\nFor the commands listed above, `-Switch:$false` results in the same behavior as `-Switch` or `-Switch:$true`.\n\n### Environment data\n\n```powershell\nName Value\n---- -----\nPSVersion 7.6.0-preview.3\nPSEdition Core\nGitCommitId 7.6.0-preview.3\nOS Microsoft Windows 10.0.19045\nPlatform Win32NT\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0, 5.0, 5.1…}\nPSRemotingProtocolVersion 2.3\nSerializationVersion 1.1.0.1\nWSManStackVersion 3.0\n```","author":{"url":"https://github.com/surfingoldelephant","@type":"Person","name":"surfingoldelephant"},"datePublished":"2025-03-26T16:55:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/25242/PowerShell/issues/25242"}
| 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:0371a957-9944-ac2c-640d-1d07f3cf4d1a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BD56:306D2B:10177E7:167F61A:6A4E910B |
| html-safe-nonce | f4e348053ed69e0c701c0804680ac0f545ba6303b5a5c23667013d4347a92f04 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDU2OjMwNkQyQjoxMDE3N0U3OjE2N0Y2MUE6NkE0RTkxMEIiLCJ2aXNpdG9yX2lkIjoiNDM2NTcwMzE1NDI5MDgyMzQzNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ed4ecd099a70872fa1ce3f16f2a9e5db12750b01ae1a5b3730e9a07cd26d14a0 |
| hovercard-subject-tag | issue:2950254094 |
| 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/25242/issue_layout |
| twitter:image | https://opengraph.githubassets.com/09eb6564c48ab3137c0e9137df1afbd7a3e9fdfe24c1fd19ab234e80dd5880b1/PowerShell/PowerShell/issues/25242 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/09eb6564c48ab3137c0e9137df1afbd7a3e9fdfe24c1fd19ab234e80dd5880b1/PowerShell/PowerShell/issues/25242 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | surfingoldelephant |
| hostname | github.com |
| expected-hostname | github.com |
| None | 41b6ab3ba6d20a71766ac245b5a4a94c6fc672a9cd4da7d44c1b33ab8bf6a21c |
| 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 | e6a744804e8e70f97b4d5a18a94dcc63db22f97a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width