Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add Where-Object -Not support #3529

Copy link
Copy link
@ChrisMagnuson

Description

@ChrisMagnuson
Issue body actions

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
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    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

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.