Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Force Powershell to run as x64-bit if required.
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