none
Compound Where Clause creating an OR -- POWERSHELL RRS feed

  • Question

  • What am I doing wrong here??

    where {$_.'Number of Failures' -ge 1 -AND $_.showrepl_columns -ne 'showrepl_INFO'}

    I need the above to be an OR not an AND statement.  How do you do OR's in a compound where statement???

    Tuesday, December 9, 2014 7:41 PM

Answers

  • Type the characters "-", "O", "R" instead of "-","A","N","D".  Why is that a problem?

    ¯\_(ツ)_/¯

    • Marked as answer by kokopelli2305 Tuesday, December 9, 2014 9:14 PM
    Tuesday, December 9, 2014 7:56 PM

All replies

  • Type the characters "-", "O", "R" instead of "-","A","N","D".  Why is that a problem?

    ¯\_(ツ)_/¯

    • Marked as answer by kokopelli2305 Tuesday, December 9, 2014 9:14 PM
    Tuesday, December 9, 2014 7:56 PM
  • That is great but it is not working but maybe the issue is somewhere else.  I could not find any reference to -OR so I figured that was wrong and the reason for the failure.  If I just do where {$_.'Number of Failures' -ge 1} it works.  Trying to add in a second command and I think I just found my problem.

    Later I have $results = $results | where {$_.'Number of Failures' -gt 1 }

    I need to build upon that also!

    Tuesday, December 9, 2014 8:08 PM

  • PS C:\> help about_Operators


    -- Bill Stewart [Bill_Stewart]

    Tuesday, December 9, 2014 8:38 PM
    Moderator
  • That is great but it is not working but maybe the issue is somewhere else.  I could not find any reference to -OR so I figured that was wrong and the reason for the failure.  If I just do where {$_.'Number of Failures' -ge 1} it works.  Trying to add in a second command and I think I just found my problem.

    Later I have $results = $results | where {$_.'Number of Failures' -gt 1 }

    I need to build upon that also!

    What are your trying to OR.  Say it in a plain english sentence using OR in the sentence.  I suspoect you are ahving a logic crisis which comes from not understanding what logical operators are.  Start with Bill's suggestion and then write a sentence.

    By the way.  It is either greater then 1,  equal to 1 OR less than 1.  It cannot be any two of those things at the same time.

    ($x -ge 1 -OR $x -gt 1) makes very little sense.  It is the same as the first clause so the second clause menas nothing and will never be used.


    ¯\_(ツ)_/¯



    • Edited by jrv Tuesday, December 9, 2014 10:11 PM
    Tuesday, December 9, 2014 10:08 PM