How to execute powershell script in 64 bit machine?

廉价感情. 提交于 2019-12-13 08:45:55

问题


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?


回答1:


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   
}


来源:https://stackoverflow.com/questions/9991752/how-to-execute-powershell-script-in-64-bit-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!