Occasionally it might be interesting to know whether your current PowerShell session is running in 64-bit. This tip describes how to determine this and how to start either a 32 or 64-bit session of PowerShell. To quickly determine if you current PowerShell session is 32 or 64-bit use the following code:
[System.IntPtr]::Size |
There are two possible results from this code:
- 4 – x86
- 8 – x64
Keep this in mind, especially if you intend to execute memory dependent tasks in Powershell, the testing if the script is executing in a 64 bit context is a good idea.
If a system is 64-bit the following two paths are available for the PowerShell executable:
- C:\WINDOWS\SysWOW64\WindowsPowerShell\v1.0\powershell.exe (32-bit)
- C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe (64-bit)