How can I use WMI and Powershell to determine if a computer running a 32-bit operating system can support a 64-bit operating system?

Below is a sample Powershell (Windows Powershell - WPS)  script that will detect if a computer that is running a 32-bit operating system will support a 64-bit operating system using WMI (Windows Management Instrumentation). 

$strComputerName = "."
$strCpuArchitecture = ""
$intCurrentAddressWidth = 0
$intSupportableAddressWidth = 0

$objWmi = Get-WmiObject -class "Win32_Processor" -namespace "root\cimV2" -computer $strComputerName

$intCurrentAddressWidth = $objWmi.AddressWidth
$intSupportableAddressWidth = $objWmi.DataWidth

switch ($objWmi.Architecture)
{
  0 {$strCpuArchitecture = "x86"}
  1 {$strCpuArchitecture = "MIPS"}
  2 {$strCpuArchitecture = "Alpha"}
  3 {$strCpuArchitecture = "PowerPC"}
  6 {$strCpuArchitecture = "Itanium"}
  9 {$strCpuArchitecture = "x64"}
}

if ($intCurrentAddressWidth -eq $intSupportableAddressWidth)
{
  "System Type: $intCurrentAddressWidth-bit operating system - Processor Architecture: $strCpuArchitecture"
}
else
{
  "System Type: $intCurrentAddressWidth-bit operating system ($intSupportableAddressWidth-bit capable) - Processor Architecture: $strCpuArchitecture"
}

 

Sample Output (32-bit Windows Vista with a 64-bit capable CPU):

System Type: 32-bit operating system (64-bit capable) - Processor Architecture: x64

32-bit Windows Vista with a 64-bit capable CPU 

 

For more information on Windows Powershell:
https://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx 

For more information on downloading Windows Powershell v1:
https://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx