To determine in your script which version of PowerShell you are using, you can use the following helper functions (kindly provided by JaredPar the answer to the corresponding question):
# Is this a Wow64 powershell host function Test-Wow64() { return (Test-Win32) -and (test-path env:\PROCESSOR_ARCHITEW6432) } # Is this a 64 bit process function Test-Win64() { return [IntPtr]::size -eq 8 } # Is this a 32 bit process function Test-Win32() { return [IntPtr]::size -eq 4 }
The functions above use the fact that the size for System.IntPtr is platform specific. These are 4 bytes on a 32-bit machine and 8 bytes on a 64-bit machine.
Note that it is worth noting that the location of the 32-bit and 64-bit versions of Powershell is somewhat misleading. The 32-bit PowerShell is located in C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe , and the 64-bit version of PowerShell is in C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe , courtesy of This article .
MagicAndi Dec 21 '11 at 11:19 2011-12-21 11:19
source share