Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining 32/64 bit in Powershell

Tags:

powershell

I am trying to create a couple lines of code that will pull from WMI if a machine is either 32/64 bit and then if it is 64 do this .... if it is 32bit do this...

Can anyone help?

like image 910
Josh D'Ambrosio Avatar asked Aug 13 '15 00:08

Josh D'Ambrosio


People also ask

How do I tell if I have 32 or 64-bit PowerShell?

If HKLM\Software\WOW6432Node\Microsoft\Office exists, then Office is 32-bit. If HKLM\Software\WOW6432Node\Microsoft\Office does not exist, but HKLM\Software\Microsoft\Office does exist, then Office is 64-bit. If HKLM\Software\WOW6432Node does not exist, then Windows and Office are 32-bit.

How can I tell if PowerShell is 32-bit?

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 I determine 32 or 64-bit Windows 10?

It's easy enough to check. In Windows 10, go to Settings > System > About or type About in the Windows 10 search box. Under the Device specifications heading, you'll see it at System type: "64-bit operating system, x64-based processor" means you're covered.


1 Answers

There's two boolean static methods in the Environment you can inspect and compare, one looks at the PowerShell process, one looks at the underlying OS.

if ([Environment]::Is64BitProcess -ne [Environment]::Is64BitOperatingSystem)
{
"PowerShell process does not match the OS"
}
like image 163
David Cobb Avatar answered Sep 17 '22 13:09

David Cobb