0

I have a script that checks for installed Adobe components. It searches the registry. It works fine until you get to a computer that doesn't allow remote registry access. I tried using the Win32_Product command. Everywhere on the net they say to avoid this but I can't find any other solution.

The thruth is that besides that it is slow, Adobe is not in the WMI list!

This is the registry method:

$UninstallRegKeys = @(
    "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
    "SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
)
if (Test-Connection -ComputerName $srv -Count 1 -EA 0) {
    foreach ($UninstallRegKey in $UninstallRegKeys) {
        try {
            $HKLM   = [microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',$srv)
            $UninstallRef  = $HKLM.OpenSubKey($UninstallRegKey)
            $Applications = $UninstallRef.GetSubKeyNames()
        } catch {
            $output.appendtext("Failed to read the registry entry. Probably no remote rights!`r`n")
            $regfail = 1
            continue
        }
    }
    foreach ($App in $Applications) {
        $AppRegistryKey = $UninstallRegKey + "\\" + $App
        $AppDetails = $HKLM.OpenSubKey($AppRegistryKey)
        $AppGUID = $App
        $AppDisplayName  = $($AppDetails.GetValue("DisplayName"))
        if ($AppDisplayName -split ' ' -contains "Adobe") {
            $AppVersion   = $($AppDetails.GetValue("DisplayVersion"))
            $output.appendtext("Name          : " + $AppDisplayName + "`r`n")
            $output.appendtext("Version       : " + $AppVersion + "`r`n")
        }
    }

This is the Win32_Product method:

$appinfo = Get-WmiObject Win32_Product | Select-Object Name, Version
foreach ($appi in $appinfo) {
    if ($Appi.name -split ' ' -contains "Adobe") {
        $output.appendtext("Name          : " + $Appi.name + "`r`n")
        $output.appendtext("Version       : " + $Appi.version + "`r`n")
    }
}

Any other method on how to find Adobe? I thought also about looking for the Adobe folder but because every version has a different style it might be difficult.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Zsolt
  • 39
  • 1
  • 3
  • 9
  • If the remote registry service is not running why not run it and try a second time? `Get-Service -Name remoteregistry -ComputerName $computer | Set-Service -Status Running` You could even check it before hand and run it so you only have to make an attempt to access the registry once. – Matt Jan 26 '16 at 12:52
  • I am not allowed to bring changes to the terminals. They are desktops of the clients. – Zsolt Jan 26 '16 at 12:56
  • I would also suggest proper inventory software like LanSweeper or something similar. WMI is going to be slow.... no way of avoiding that fact with WMI. – Matt Jan 26 '16 at 12:59
  • One thing ..... `($Appi.name -split ' ' -contains "Adobe")` should just be `($Appi.name -match "\bAdobe\b")` saves the split – Matt Jan 26 '16 at 13:01
  • Ok, I will change that. But how come that when I test it on my local machine I get all Adobe components from the WMI but on the remote machines not? I also tested it on machines I had acces to registry, it listed all and when looking in WMI they were also missing. – Zsolt Jan 26 '16 at 13:03
  • 1
    I think you don't want to see this but here is the answer to that question: http://stackoverflow.com/questions/673233/wmi-installed-query-different-from-add-remove-programs-list. You are only seeing software that uses the windows installer when using the WMI class. Also about the registry.... starting the service is a temporary measure... also could just stop the service if you had to start it. – Matt Jan 26 '16 at 13:04

0 Answers0