问题
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.
- Using the registry keys
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
andHKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
(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)" }
}
}
- 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
- 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 withGet-Item
to read theVersion
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