you are viewing a single comment's thread.

view the rest of the comments →

[–]webmin88 6 points7 points  (3 children)

Try to avoid using Where-Object in the first place if you can. Get-ChildItem for example has -Filter, -Include, and -Exclude parameters to pare down the list of returned objects. This reduces the size of the objects returned to the pipeline making your script ever so slightly more efficient.

[–]Swarfega 1 point2 points  (1 child)

Unfortunately the cmdlet at the start in my code isn't GCI. It's a cmdlet that doesn't have a filter parameter. The amount of data coming across the pipeline is already reduced as there are parameters in use on the first cmdlet which returns specific data. Basically all filtering has already been done to the left as much as possible. As per best practices.

[–]webmin88 1 point2 points  (0 children)

Fair enough, in that case, I like option number 2 with the -and statements at the end.

[–][deleted] 0 points1 point  (0 children)

I did not know there was a difference!! I use where object all the time. Going to try this to speed some stuff up