Multiple Conditions

Topics: Developer Forum
May 6, 2010 at 3:17 PM

$a = 4

Can't find doc on this so wanted to ask.

What do I use if I wanted to compare 2 or more conditions in an If, Where, Do, etc?

Does "and" or "or" need to be specified as & and |?

If ($a -eq 5) or ($a -eg 6) ...

If ($a -eq 5) and ($a -eg 6) ...

May 6, 2010 at 3:42 PM

Duh!

( ($age -ge 18) -and ($sex -eq "m") )

Developer
May 6, 2010 at 3:43 PM
if ( ( $a -eq 5) -or ($a -eq 6) ) { ... }
 
see:
 
ps> get-help about_operators | more
 
also:
 
about_Arithmetic_Operators
about_Assignment_Operators
about_Comparison_Operators
about_Logical_Operators
about_Type_Operators
about_Split
about_Join
about_Redirection

On Thu, May 6, 2010 at 11:17 AM, jbruns2010 <notifications@codeplex.com> wrote:

From: jbruns2010

$a = 4

Can't find doc on this so wanted to ask.

What do I use if I wanted to compare 2 or more conditions in an If, Where, Do, etc?

Does "and" or "or" need to be specified as & and |?

If ($a -eq 5) or ($a -eg 6) ...

If ($a -eq 5) and ($a -eg 6) ...

Read the full discussion online.

To add a post to this discussion, reply to this email (Pscx@discussions.codeplex.com)

To start a new discussion for this project, email Pscx@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--

---
404 signature missing
May 6, 2010 at 4:03 PM
Edited May 6, 2010 at 4:10 PM

Super, thanks.