Title: -[Operator]:$false not respected in Where-Object · Issue #26480 · PowerShell/PowerShell · GitHub
Open Graph Title: -[Operator]:$false not respected in Where-Object · Issue #26480 · PowerShell/PowerShell
X Title: -[Operator]:$false not respected in Where-Object · Issue #26480 · 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/26480
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"-[Operator]:$false not respected in Where-Object","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\nThis is a sub-issue of #25242.\r\n\r\nThe cmdlet `Where-Object` does not respect explicit `$false` values for any of its 31 operator switch parameters. This affects all comparison and logical operator switches.\r\n\r\n**Example with `-EQ`:**\r\n\r\n```powershell\r\n$data = @(\r\n [PSCustomObject]@{ Name = 'Alice'; Age = 25 }\r\n [PSCustomObject]@{ Name = 'Bob'; Age = 30 }\r\n)\r\n$result = $data | Where-Object Name -EQ:$false\r\n$result.Count\r\n```\r\n\r\n**Example with `-GT`:**\r\n\r\n```powershell\r\n$result = $data | Where-Object Age -GT:$false\r\n$result.Count\r\n```\r\n\r\n### Expected behavior\r\n\r\n```console\r\nPS\u003e $result = $data | Where-Object Name -EQ:$false\r\nPS\u003e $result.Count\r\n2\r\n```\r\n\r\nWhen `-EQ:$false` is specified, the `-EQ` operator should not be active. The cmdlet should fall back to default boolean evaluation of the property value, returning all objects where `Name` is truthy (non-empty strings).\r\n\r\nSimilarly for other operators, `-[Operator]:$false` should behave as if the operator switch was not specified at all.\r\n\r\n### Actual behavior\r\n\r\n```console\r\nPS\u003e $result = $data | Where-Object Name -EQ:$false\r\nPS\u003e $result.Count\r\n0\r\n```\r\n\r\nThe `-EQ:$false` is incorrectly interpreted as `-EQ $false`, comparing the `Name` property against the boolean value `$false` instead of disabling the `-EQ` operator. This causes the filter to return no results because no `Name` values equal `$false`.\r\n\r\n### Affected parameters\r\n\r\nAll 31 operator switch parameters are affected:\r\n\r\n| Category | Parameters |\r\n|----------|------------|\r\n| Equality | `-EQ`, `-CEQ`, `-NE`, `-CNE` |\r\n| Comparison | `-GT`, `-CGT`, `-GE`, `-CGE`, `-LT`, `-CLT`, `-LE`, `-CLE` |\r\n| Pattern | `-Like`, `-CLike`, `-NotLike`, `-CNotLike`, `-Match`, `-CMatch`, `-NotMatch`, `-CNotMatch` |\r\n| Containment | `-Contains`, `-CContains`, `-NotContains`, `-CNotContains`, `-In`, `-CIn`, `-NotIn`, `-CNotIn` |\r\n| Type | `-Is`, `-IsNot` |\r\n| Logical | `-Not` |\r\n\r\n### Error details\r\n\r\nNo error is thrown. The cmdlet executes but misinterprets the explicit `$false` value as an operand rather than as a directive to disable the switch.\r\n\r\n### Environment data\r\n\r\n```powershell\r\nPS\u003e $PSVersionTable\r\n\r\nName Value\r\n---- -----\r\nPSVersion 7.5.4\r\nPSEdition Core\r\nGitCommitId 7.5.4\r\nOS Microsoft Windows 10.0.26100\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### Visuals\r\n\r\n_No response_","author":{"url":"https://github.com/yotsuda","@type":"Person","name":"yotsuda"},"datePublished":"2025-11-18T23:21:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/26480/PowerShell/issues/26480"}
| 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:c4cbca68-a4c7-e638-1c08-aec0bd4afc71 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CFC8:2AD6D5:3C589:5299F:6A5057EB |
| html-safe-nonce | 3473351d6ec2de96279aef498bf59bb9ccef5680ed9099ed4a818cec5ec2572c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRkM4OjJBRDZENTozQzU4OTo1Mjk5Rjo2QTUwNTdFQiIsInZpc2l0b3JfaWQiOiIxMTUyODAwMzE1Mjk4MzA2MDI3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 00ca759b31448942bedfcd9d8dfe6f9c927b238e0f50f1ec7ee0baead8ef49f6 |
| hovercard-subject-tag | issue:3640367725 |
| 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/26480/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e1decf1761ed97b713f9a12a7a0debeea4695a073b289207e9fa3dc165b21685/PowerShell/PowerShell/issues/26480 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e1decf1761ed97b713f9a12a7a0debeea4695a073b289207e9fa3dc165b21685/PowerShell/PowerShell/issues/26480 |
| 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 | yotsuda |
| hostname | github.com |
| expected-hostname | github.com |
| None | d6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb |
| 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 | 7ac0ad2f2c7e4b9056617355fd9e33e22b0c8df9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width