Running 32-bit Code on the Same Machine

by Nov 16, 2016

If you need to run 32-bit PowerShell code from within a 64-bit script, and provided you are Administrator and use remoting, you can remote against your own system:

$code = {
  [IntPtr]::Size
  Get-Process
}


Invoke-Command -ScriptBlock $code -ConfigurationName microsoft.powershell32 -ComputerName $env:COMPUTERNAME

This will run the script block contained in $code in a 32-bit environment. The pointer returns a size of 4 as proof. When you run the script block directly, it returns a size of 8 bytes (64-bit).

Twitter This Tip! ReTweet this Tip!