1

Does anyone have a script to scan a network for a list of hosts to determine if HP Fortify software is installed and provide the version?

I tried using a PowerShell script that scans the add/remove section of the registry but Fortify does not appear there.

Any assistance would be most appreciated!

sodawillow
  • 12,497
  • 4
  • 34
  • 44
bbcompent1
  • 494
  • 1
  • 10
  • 25
  • 1
    It doesn't show up in the registry? Interesting. You can always check for files (.exe, .dll) existing in the install directory and verify file versions that way. – bentek Dec 07 '15 at 14:18
  • 1
    Also check the Win32_Product WMI class. – EBGreen Dec 07 '15 at 14:23
  • Hi, please double-check in `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall` AND `HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall`, you should find it there. – sodawillow Dec 07 '15 at 14:42

1 Answers1

3

You have at least 3 ways of accomplishing this.

  1. Using the registry keys HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall and HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninst‌​all (on 64-bit Windows versions) : if the program has been installed with an installer, it should be listed here.

Here's how you can start:

$base = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, $ComputerName)
if($key = $base.OpenSubKey("SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall")) {
    foreach($subkey in $key.GetSubKeyNames()) {
        $name = ($key.OpenSubKey($subkey)).GetValue("DisplayName")
        $version = ($key.OpenSubKey($subkey)).GetValue("DisplayVersion")
        if($name) { "$name ($version)" }
    }
}
  1. Using the Win32_Product WMI class (slower, and not all programs appear here):

Get-WmiObject -ComputerName "127.0.0.1" -Class Win32_Product | Select Name,Version

  1. Using the files for the application themselves, locating the executable that holds the version you need in the C:\Program Files\HP_Fortify directory (or \\$computerName\c$\Program Files\HP_Fortify for a remote computer). You will be able with Get-Item to read the Version property of the desired file.

With example path C:\Program Files\HP_Fortify\main_service.exe on computer SERVER001:

$computerName = "SERVER001"
$exePath = "\\$computerName\c$\Program Files\HP_Fortify\main_service.exe"

if(Test-Path $exePath) {
    (Get-Item $exePath).VersionInfo.ProductVersion
} else {
    "file not found: $exePath"
}
sodawillow
  • 12,497
  • 4
  • 34
  • 44