title: Dynamically switch from 64bit to 32bit powershell
body: <p>I have a script that needs to run in 32bit powershell. I want to, at run time, determine if it is running in 32 or 64 bit powershell, and if 64bit, switch dynamically to 32bit. </p>
  
  <p>Basically the exact opposite of <a href="http://www.cosmonautdreams.com/2013/09/03/Getting-Powershell-to-run-in-64-bit.html" rel="nofollow noreferrer">this.</a></p>
  
  <pre><code>if ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64") {
  write-warning "Y'arg Matey, we're off to 64-bit land....."
  if ($myInvocation.Line) {
      &amp;"$env:WINDIR\sysnative\windowspowershell\v1.0\powershell.exe" -NonInteractive -NoProfile $myInvocation.Line
  }else{
      &amp;"$env:WINDIR\sysnative\windowspowershell\v1.0\powershell.exe" -NonInteractive -NoProfile -file "$($myInvocation.InvocationName)" $args
  }
  exit $lastexitcode
  }
  </code></pre>
  
  <p>But for some reason I can not figure out how to reverse this. Please help.</p>