# encoding: ascii
# api: powershell
# title: Force 64 bit for script
# description: Place this at the head of a ps1 script to ensure that if it’s run in a 32 bit shell (like the NuGet package manage console for example) that it will be relaunched in a 64 bit powershell process, and will it will also pass along any arguments to the child process (please use primitives like string, bool etc for arguments as they are being marshaled to another win32 process – live objects will not work.)
# version: 0.1
# type: script
# author: Oisin Grehan
# license: CC0
# x-poshcode-id: 3827
# x-archived: 2017-05-13T16:25:49
# x-published: 2013-12-18T07:11:00
#
#
# am I running in 32 bit shell?
if ($pshome -like "*syswow64*") {
	
	write-warning "Restarting script under 64 bit powershell"

	# relaunch this script under 64 bit shell
	# if you want powershell 2.0, add -version 2 *before* -file parameter
	& (join-path ($pshome -replace "syswow64", "sysnative") powershell.exe) -file `
		(join-path $psscriptroot $myinvocation.mycommand) @args

	# exit 32 bit script
	exit
}

# start of script for 64 bit powershell

write-warning "hello from $pshome"
write-warning "My original arguments $args"
