locked
Powershell - If with 2 variables RRS feed

  • Question

  • Hi,

    Probably a little noob, but anyway...

    I have a script where I'm attempting put some logic in.  I want to compare two variables using an IF.  The 2 variables at some point will be the same as the script goes through the loop and does what it needs to do.

    Loop 1:  $VAR1 = Apples / $VAR2 = Oranges

    Loop 2:  $VAR1 = Apples / $VAR2 = Apples

    Can I use If ($VAR1 -eq $VAR2) to compare the 2?

    Regards

    Friday, June 2, 2017 2:46 AM

Answers

  • Sure.

    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
    Celebrating 20 years of providing Exchange peer support!

    Friday, June 2, 2017 3:33 AM

All replies

  • Sure.

    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
    Celebrating 20 years of providing Exchange peer support!

    Friday, June 2, 2017 3:33 AM
  • I thought we weren't supposed to compare apples and oranges.


    \_(ツ)_/

    • Proposed as answer by Ed CrowleyMVP Friday, June 2, 2017 3:52 AM
    Friday, June 2, 2017 3:38 AM
  • Maybe it was the logic that I was using, which is why it wasn't giving me the results I was expecting.

    However, all good now.

    Monday, June 5, 2017 1:58 AM
  • Please feel free to mark responses as the answer and/or vote them as helpful as appropriate.

    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
    Celebrating 20 years of providing Exchange peer support!

    Monday, June 5, 2017 6:13 AM
  • I guess we can
    Tuesday, June 13, 2017 8:53 PM