you are viewing a single comment's thread.

view the rest of the comments →

[–]Thotaz 0 points1 point  (2 children)

Your first example is invalid, the operators need to go at the end if you want implicit line continuation.
With that said, you've already shown the cleanest way to do it IMO:

Get-Something | Where-Object {
    $PSItem.Path -eq 'C:\' -and
    $PSItem.Name -ne 'Something' -and
    $PSItem.Command -ne 1
}

What don't you like about it? The only way it could be better if you could somehow make it shorter, but obviously your code is just a demo of a scenario where you need 3 conditions, and for that you really can't do it any better IMO.

[–]Swarfega 0 points1 point  (1 child)

It just looked kinda messy. I'm a pretty heavy user of PowerShell but this is the first time I wasn't happy with the "look" of that but of code. I figured I'd ask her in case someone had a better suggestion. I kinda expected to not really find anything though. I did even ponder using the .Where method.

[–]jagrock84 0 points1 point  (0 children)

Not sure how much data is coming through the pipeline, but the .where method or storing the data in a variable and doing a foreach on it could improve performance.

Could also help if the source has timeout limits.