Created
October 27, 2016 10:31
-
-
Save talatham/ad406d5428ccec641f075a7019cd29a8 to your computer and use it in GitHub Desktop.
Force Powershell to run as x64-bit if required.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (($pshome -like "*syswow64*") -and ((Get-WmiObject Win32_OperatingSystem).OSArchitecture -like "64*")) { | |
write-warning "Restarting script under 64 bit powershell" | |
# relaunch this script under 64 bit shell | |
& (join-path ($pshome -replace "syswow64", "sysnative")\powershell.exe) -file $myinvocation.mycommand.Definition @args | |
# This will exit the original powershell process. This will only be done in case of an x86 process on a x64 OS. | |
exit | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment