Melon Man
Melon Man

Reputation: 185

Adding multiple clauses in Where-Object statement

I know others have posted about this, but every thing i've tried so far hasn't worked. The issue i'm running into is that when I add brackets around my Where-Object statement, it turns the column that i'm trying to filter on into a function. Thus not allowing it to run.

$AgentList | Select-Object Leaf.NodeName, Properties.OSType, PropsView.version, BranchNode.Node | Where-Object{ (PropsView.version -lt '5.5.0.447') -and (Properties.OSType -ne 'Mac OS X')} | Sort-Object -Property EPOBranchNode.NodeTextPath2 -Descending

I'm hoping to be able to filter on both PropsView.version and Properties.OSType at the same time. At the moment I can do one or the other, but right when I try to add both I run into the error.

The term 'PropsView.version' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Upvotes: 0

Views: 459

Answers (1)

Melon Man
Melon Man

Reputation: 185

$AgentList | Select-Object Leaf.NodeName, Properties.OSType, PropsView.version, BranchNode.Node | Where-Object{ ($_.'PropsView.version' -lt '5.5.0.447') -and ($_.'Properties.OSType' -ne 'Mac OS X')} | Sort-Object -Property EPOBranchNode.NodeTextPath2 -Descending

Just needed to add the $_. and then single quotes around the column i'm sorting. It was the single quotes that I wasn't adding that messed me up. Thanks for the help everyone!

Upvotes: 1

Related Questions