问题
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