Logic to detect system architecture for windows machine are
32-bit or x64-bit from power-shell. This is very small function but admin and
script-er use a lot in day to day task .I am sharing one function which will deduct
bitness of windows machine.We can check OS architecture from remote machine also.
#################################################################################
Function GetArchOS($sArchOS)
{
$sArchOS = (Get-WmiObject Win32_OperatingSystem).OSArchitecture
If($sArchOS -eq '64-bit' )
{
$Script:sArchOS = "x64"
Write-Host $sArchOS
}
Elseif($sArchOS -eq '32-bit')
{
$Script:sArchOS = "x86"
Write-Host $sArchOS
}
}
GetArchOS
#################################################################################
################################## Remote Machine ################################
$sComputerName='CRP-APPTESTW64'
$sOSArch = (Get-WmiObject Win32_OperatingSystem -computername $sComputerName).OSArchitecture
Write-host $sOSArch
#################################################################################
################################ Win-32_Processor #################################
$sComputerName='CRP-APPTESTW64'
$sOSArch = Get-WmiObject -Class Win32_Processor -ComputerName $sComputerName| Select-Object AddressWidth
Write-host $sOSArch
#################################################################################
Note:- Please test script in your test environment before running in production directly.