Detect if HP Fortify is installed on remote computers

谁说胖子不能爱 提交于 2020-01-05 21:10:12

问题


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!


回答1:


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"
}


来源:https://stackoverflow.com/questions/34135657/detect-if-hp-fortify-is-installed-on-remote-computers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!