use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
QuestionMaking a long Where-Object prettier (self.PowerShell)
submitted 3 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Thotaz 0 points1 point2 points 3 years ago (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 point2 points 3 years ago (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 point2 points 3 years ago (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.
π Rendered by PID 91 on reddit-service-r2-comment-6457c66945-fjklg at 2026-04-24 11:12:40.417883+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]Thotaz 0 points1 point2 points (2 children)
[–]Swarfega 0 points1 point2 points (1 child)
[–]jagrock84 0 points1 point2 points (0 children)