PowerShell Server: Executing scripts in an x86 runspace

In some situations a user will have a script or module that is not compatible with a 64-bit architecture. While PowerShell Server cannot be configured to run in a 32-bit runspace itself, it is easy to execute a script in a 32-bit runspace by using the following script:

if ($env:Processor_Architecture -ne "x86")
{
     write-warning "Running x86 PowerShell..."
     &"$env:windir\syswow64\windowspowershell\v1.0\powershell.exe" -noninteractive -noprofile -file "C:\Path	o\script.ps1" -executionpolicy bypass
     exit
}

# rest of your code

We appreciate your feedback.  If you have any questions, comments, or suggestions about this article please contact our support team at kb@nsoftware.com.