简体   繁体   中英

How to execute powershell script in 64 bit machine?

I have written a powershell script and send to my team mates.

One of my teammate when he was right click and [Run with powershell] execute the script it did not work.

He told that it is Win7 64 bit machine.

Then i manually opened 32 bit Powershell and use the " Powershell -file <Filename> " and executed.

In 64 bit environment, can't we simply execute by right click and Run with powershell?

If for some reason your script can run only in x86 architecture add this at start in your script:

if ($env:Processor_Architecture -ne "x86")   
 {
      write-warning "Running PowerShell x86"   
         &"$env:windir\syswow64\windowspowershell\v1.0\powershell.exe" -noninteractive -noprofile -file $myinvocation.Mycommand.path -executionpolicy bypass   
         exit   
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM