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?
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.
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.
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.
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"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With