# Check whether product is installed
$serviceName='windows_exporter'
function checkUninstall($serviceName){
    $cpuArchitecture32bitPointerSize=4
    $path=if ([IntPtr]::Size -eq $cpuArchitecture32bitPointerSize) {
        'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
    }else{
        @('HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*',
          'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*')
    }
    Get-ItemProperty $path |.{process{ if ($_.DisplayName -eq $serviceName -and $_.UninstallString) { $_ } }} |
    Select-Object DisplayName, Publisher, InstallDate, DisplayVersion, UninstallString
}
checkUninstall $serviceName