I am writing a Powershell script which will be integrated into a product designed for 32 bit Windows machines. So on invocation it will by default run on the x86 Powershell even on 64 bit machines. One of the lines needs to be run on a 64 bit shell for accurate results. Tried doing this :
#Above this is the ongoing script in 32bit session
if ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64") {
#write-warning "Excecuting the script under 64 bit powershell"
if ($myInvocation.Line) {
[System.IntPtr]::Size
&"$env:systemroot\sysnative\windowspowershell\v1.0\powershell.exe" -NonInteractive -NoProfile
#Statement block
}else{
&"$env:systemroot\sysnative\windowspowershell\v1.0\powershell.exe" -NonInteractive -NoProfile $args
#Statement block
}
}
#Below this is the remaining Script in 32 bit session
I am not able to pass the control flow to the new session and take it back. All it does is start the 64 bit shell inside the already running 32 bit shell. Any possible way to do this and also return the values printed by the new shell?