
When Ninja executes a PowerShell script (via a custom script that you have added to your Script Library), it does so from a 32-bit console. Adding the script below into your PowerShell script will ensure that it gets executed utilizing a 64-bit console.
#############################################################
#If Powershell is running the 32-bit version on a 64-bit machine, we
#need to force powershell to run in 64-bit mode .
#############################################################
if ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64") {
write-warning "Executing your script in 64-bit mode"
if ($myInvocation.Line) {
&"$env:WINDIRsysnativewindowspowershellv1.0powershell.exe" -NonInteractive -NoProfile $myInvocation.Line
}else{
&"$env:WINDIRsysnativewindowspowershellv1.0powershell.exe" -NonInteractive -NoProfile -file "$($myInvocation.InvocationName)" $args
}
exit $lastexitcode
}
write-host "Main script body"
#End