I wrote this script, it's based on the version of excel.exe.
It then reads the name and version from registry.
$x32 = ${env:ProgramFiles(x86)} + "\Microsoft Office"
$x64 = $env:ProgramFiles + "\Microsoft Office"
$OK = $true
if (Test-Path -Path $x32) {$Excel32 = Get-ChildItem -Recurse -Path $x32 -Filter "EXCEL.EXE"}
if (Test-Path -Path $x64) {$Excel64 = Get-ChildItem -Recurse -Path $x64 -Filter "EXCEL.EXE"}
if ($Excel32) {$Excel = $Excel32}
if ($Excel64) {$Excel = $Excel64}
if ($Excel32 -and $Excel64) {"Error: x32 and x64 installation found." ; $Excel32.Fullname ; $Excel64.Fullname ; $OK = $false}
if ($Excel.Count -gt 1) {"Error: More than one Excel.exe found." ; $Excel.Fullname ; $OK = $false}
if ($Excel.Count -eq 0) {"Error: Excel.exe not found." ; $OK = $false}
if ($OK) {
$DisplayVersion = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" -Name "DisplayVersion" -ErrorAction SilentlyContinue | Where-Object {$_.DisplayVersion -eq $Excel.VersionInfo.ProductVersion -and $_.PSChildName -notlike "{*}"}
$Office = Get-ItemProperty -Path $DisplayVersion.PSPath
$Office | ForEach-Object {"Product: " + $_.DisplayName + $(if ($_.InstallLocation -eq $x32) {", 32 Bit"} else {", 64 Bit"}) + ", Productversion: " + $_.PSChildName + ", Build: " + $_.DisplayVersion}
}
I get this outputs on different systems.
An emtpy line is the separator between the various outputs.
Product: Microsoft Office Professional Plus 2019 - de-de, 64 Bit, Productversion: ProPlus2019Retail - de-de, Build: 16.0.14430.20306
Product: Microsoft Office Professional Plus 2019 - de-de, 64 Bit, Productversion: ProPlus2019Volume - de-de, Build: 16.0.10379.20043
Product: Microsoft 365 Apps for Enterprise - de-de, 64 Bit, Productversion: O365ProPlusRetail - de-de, Build: 16.0.14430.20306
Product: Microsoft Office Professional Plus 2019 - de-de, 64 Bit, Productversion: ProPlus2019Volume - de-de, Build: 16.0.10379.20043
Product: Microsoft Office Profesional Plus 2019 - es-es, 64 Bit, Productversion: ProPlus2019Volume - es-es, Build: 16.0.10379.20043
Error: More than one Excel.exe found.
C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE
C:\Program Files (x86)\Microsoft Office\Office16\EXCEL.EXE
Product: Microsoft Access Runtime 2016 - de-de, 32 Bit, Productversion: AccessRuntimeRetail - de-de, Build: 16.0.10379.20043
Product: Microsoft Office Standard 2019 - de-de, 32 Bit, Productversion: Standard2019Volume - de-de, Build: 16.0.10379.20043
Product: Microsoft Office Professional Plus 2019 - de-de, 32 Bit, Productversion: ProPlus2019Volume - de-de, Build: 16.0.10377.20023
Product: Microsoft Office Professional Plus 2019 - en-us.proof, 32 Bit, Productversion: ProPlus2019Volume - en-us.proof, Build: 16.0.10377.20023
Product: Microsoft Office Profesional Plus 2019 - es-es.proof, 32 Bit, Productversion: ProPlus2019Volume - es-es.proof, Build: 16.0.10377.20023
Product: Microsoft Office Professional Plus 2019 - it-it.proof, 32 Bit, Productversion: ProPlus2019Volume - it-it.proof, Build: 16.0.10377.20023