title: Condition with a function call in PowerShell
body: <p>Something is really weird with this language. I'm trying to execute a function and use its result value as condition. This is my code:</p>
  
  <pre><code>function Get-Platform()
  {
      # Determine current Windows architecture (32/64 bit)
      if ([System.Environment]::GetEnvironmentVariable("ProgramFiles(x86)") -ne $null)
      {
          echo "x64"
          return "x64"
      }
      else
      {
          echo "x86"
          return "x86"
      }
  }
  
  if (Get-Platform -eq "x64")
  {
      echo "64 bit platform"
  }
  if (Get-Platform -eq "x86")
  {
      echo "32 bit platform"
  }
  </code></pre>
  
  <p>The expected output is this:</p>
  
  <pre><code>x64
  64 bit platform
  </code></pre>
  
  <p>But the actual output is this:</p>
  
  <pre><code>64 bit platform
  32 bit platform
  </code></pre>
  
  <p>What's going on here? How can this be fixed? I couldn't find any examples on the web that use functions inside an <code>if</code>condition. Is that possible at all in Powershell? I'm on Windows 7 with no special setup, so I have whatever PS version comes with it.</p>