-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Description
I often have the need to filter for objects that do not have a property specified or who have a falsey value for a property by doing something like the following:
$Computers = [PSCustomObject]@{
ComputerName = "SPC-1234"
IPAddress = "192.168.0.1"
},
[PSCustomObject]@{
ComputerName = "BGP-5678"
IPAddress = ""
},
[PSCustomObject]@{
ComputerName = "MGC-9101"
}
$Computers |
Where {-not $_.IPAddress }
ComputerName IPAddress
------------ ---------
BGP-5678
MGC-9101
If I am doing the opposite test I can avoid using a script block with Where-Object:
$Computers |
Where IPAddress
ComputerName IPAddress
------------ ---------
SPC-1234 192.168.0.1
I would like to be able to also avoid using a script block when using -Not which would enable the following:
$Computers |
where -not IPAddress
Metadata
Metadata
Assignees
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module