Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine if current PowerShell Process is 32-bit or 64-bit?

When running a PowerShell script on a x64-bit OS platform, how can you determine in the script what version of PowerShell (32-bit or 64-bit) the script is running on?

Background
Both 32-bit and 64-bit versions of PowerShell are installed by default on a 64-bit platform such as Windows Server 2008. This can lead to difficulties when a PowerShell script is ran that must target a specific architecture (i.e. using 64-bit for a script for SharePoint 2010, in order to consume the 64-bit libraries).

Related question:

  • What is the best way to program against powershell's x64 vs. x86 variability? This question deals with code running against both 32-bit and 64-bit architectures. My question deals with the case when you want to ensure the script only runs against the correct version.
like image 467
Tangiest Avatar asked Dec 21 '11 11:12

Tangiest


People also ask

How do you tell if you are running 32 or 64-bit PowerShell?

We can do this by simply checking the SizeOf a System. IntPtr. If the result of the above statement is 4, it is running in a 32-bit of PowerShell. If the result of the above statement is 8, it is running in a 64-bit of PowerShell.

How do you tell if a process is running 32 or 64-bit?

Open the Task Manager by simultaneously pressing the Ctrl + Shift + Esc keys on your keyboard. Then, click on the Processes tab. In the Processes tab, you see the list of processes that are running at the moment. If a program is 32-bit, near its name you should see the text: *32.

How will you identify if a process that is running is a 32bit or 64bit process type the name of the utility or the program that you will use to identify?

Launch the target program you want to check if it's 32-bit or 64-bit, then open Task Manager and go to the Details tab. Right-click on a column header and choose Select columns. Check the Platform box, and click OK. Under the Platform column, you can easily see if a particular program on you system is 32-bit or 64-bit.

How can I tell if a process is 32-bit?

To See if Process is 32-bit or 64-bit in Processes tab in Task Manager. 1 Open Task Manager in more details view. If you see (32-bit) in the process name, then the process is 32-bit. If you don't see (32-bit) in the process name, then the process is 64-bit.


1 Answers

If you're shell is running on .NET 4.0 (PowerShell 3.0):

PS> [Environment]::Is64BitProcess True 
like image 174
Shay Levy Avatar answered Oct 02 '22 13:10

Shay Levy