How to find whether 64 bit or 32 bit excel is installed via Powershell?
<p>We have written powershell function to find whether 64 bit or 32 bit msi is installed. We are checking outlook registry key as that is the one having bitness information.</p>

<p>But when user is installing only excel without outlook ,this registry key is not reliable( In 64 bit OS it is available but in 32 bit OS it is not available). </p>

<p>Following is the function we wrote to find that. Now as registry key is not available it is not working . is there any other way we can find the bitness of excel ?</p>

<pre><code>Function Get-OfficeVersionInstalled
{
    $NoExcelInstalled = '0'
    $excelApplicationRegKey = "HKLM:\SOFTWARE\Classes\Excel.Application\CurVer"
    if( Test-Path $excelApplicationRegKey)
    {
        $excelApplicationCurrentVersion = (Get-ItemProperty $excelApplicationRegKey).'(default)'

        #Get version number alone from registry value
        $($excelApplicationCurrentVersion -replace "Excel.Application.","")
    }
    else
    {
        $NoExcelInstalled
    }
}

Function Test-Excel2013AndAbove
{
    Param
    (
        [ValidateSet("x64", "x86")]
        $Edition="x64"  
    )
    $isExpectedEditionInstalled = $false
    $officeVersion = Get-OfficeVersionInstalled
    $office2013Version = 15

    if( $officeVersion -ge $office2013Version) {

    # In registry, version will be with decimal
        $officeVersion = $officeVersion+".0"

        # Outlook key is having bitness which will decide the edition. 
    # Even if outlook is not installed this key will be present.
    # This is the only place where we can reliably find the edition of Excel
        $OutlookKey = "HKLM:\SOFTWARE\Microsoft\Office\$officeVersion\Outlook"
        $OutlookWow6432NodeKey = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Office\$officeVersion\Outlook"

        if(Test-Path $OutlookKey)
        {       
            $officeRegKey = $OutlookKey
        }
        else
        {        
            $officeRegKey = $OutlookWow6432NodeKey
        }

        $BitNess = (Get-ItemProperty $officeRegKey).BitNess

        if($BitNess -eq $Edition)
        {
            $isExpectedEditionInstalled = $true
        }
        else
        {
            $isExpectedEditionInstalled = $false
        }

    }

    return $isExpectedEditionInstalled
}
</code></pre>