Title: `New-Guid -Empty` ignores an explicit `$false` value · Issue #25276 · PowerShell/PowerShell · GitHub
Open Graph Title: `New-Guid -Empty` ignores an explicit `$false` value · Issue #25276 · PowerShell/PowerShell
X Title: `New-Guid -Empty` ignores an explicit `$false` value · Issue #25276 · 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. This is one of m...
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/25276
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`New-Guid -Empty` ignores an explicit `$false` value","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\nThis is one of many instances of a shipped command that doesn't behave correctly when a switch parameter is explicitly passed a `$false` value.\n\nFor context, see:\n\n- https://github.com/PowerShell/PowerShell/issues/25242\n\n### Steps to reproduce\n\n```powershell\nNew-Guid -Empty:$false\n\n# Equivalent, with hash table splatting:\n$params = @{ Empty = $false }\nNew-Guid @params\n```\n\n### Expected behavior\n\n`New-Guid` emits a non-empty `[guid]` instance. For example:\n\n```\nGuid\n----\nd2a83da7-6092-4c06-b8de-3b9aadbd8c94\n```\n\n### Actual behavior\n\nThe `$false` value is ignored and an empty `[guid]` instance is emitted.\n\n```\nGuid\n----\n00000000-0000-0000-0000-000000000000\n```\n\n`New-Guid` uses the selected parameter set name (`Empty`), which is based on the presence of the switch parameter (_not_ its value), to determine the behavior.\n\nhttps://github.com/PowerShell/PowerShell/blob/f1943592a04d755e60400c069b6e37fb2fd6eb31/src/Microsoft.PowerShell.Commands.Utility/commands/utility/NewGuidCommand.cs#L52\n\nBehavior should be determined by the value of the `Empty` property instead.\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-04-03T10:49:07.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/25276/PowerShell/issues/25276"}
| 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:0062adac-2a34-535d-84ee-6fe21d727daf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DD2E:14FBB8:13C6043:1B5562A:6A4DE944 |
| html-safe-nonce | baa518281b152637adaf456e24717f181ab97ffc3271cf5e501210848cbb9cd4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDJFOjE0RkJCODoxM0M2MDQzOjFCNTU2MkE6NkE0REU5NDQiLCJ2aXNpdG9yX2lkIjoiNzE5MTY1MTkyNDA2NzYwODkwMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cb080b0aa6aefe19bbc33878c891a4afe2e1149e3bf6ff7d848533262664534d |
| hovercard-subject-tag | issue:2969157692 |
| 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/25276/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a39e89a8fc437f4cd44a6b9235f9435798196458fddde8042cf3a4c60131ad7e/PowerShell/PowerShell/issues/25276 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a39e89a8fc437f4cd44a6b9235f9435798196458fddde8042cf3a4c60131ad7e/PowerShell/PowerShell/issues/25276 |
| 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 | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| 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 | 1d344bdb7547fe6bca17a59bb2b8aac3dc9532a0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width