Running PowerShell on 64-bit systems

by May 2, 2011

On 64-bit systems, PowerShell will by default run in a 64-bit process. This can cause problems with snap-ins, some COM-objects (like ScriptControl)  and database drivers that are designed to run in 32-bit processes. In this case, you can run them in the 32-bit PowerShell console.

Here are two helpful lines of code to help you identify the current environment from within a script and make appropriate decisions:

$is64BitSystem = ($env:Processor_Architecture -ne "x86")
$is64BitPowerShell = [IntPtr]::Size -eq 8


$is64BitSystem returns $true if you are running on a 64-bit machine.

$is64BitPowerShell returns $true if you are running in a 64-bit PowerShell session.


Twitter This Tip!
ReTweet this Tip!