Saturday, March 24, 2012

Powershell 32 or 64 bits

A weird issue can occur in PowerShell, when it comes to installing using InstallUtil on a 64 bit machine. InstallUtil might install within the 32-bit registry part, and PowerShell will then look for the cmdlet within the 64-bit.

It is useful to find out which version of PowerShell one is running. This can be done programmatically as follows.


if ([IntPtr]::Size -eq 4){
set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\installutil
}else{
set-alias installutil $env:windir\Microsoft.NET\Framework64\v2.0.50727\installutil
}

No comments: