sasha
November 12, 2019, 3:58am
1
Hello to all PowerShell community members, thank you for letting me join.
I am a new PowerShell user and this is my first question so please don’t shoot me…
I tried to get it done using the scripts from here
https://stackoverflow.com/questions/33649043/powershell-how-to-get-antivirus-product-details
and other sources. However, I encountered a multiple errors, don’t know exactly why? Maybe because the dc trees different
from each other or maybe because each dc has different servers distributions under it, I really don’t know…
Any help will be appreciated,
thank you.
Hi Sasha,
Can you please let us know where did you stick and what is the error?
Thank you.
Definitely do not use Win32_Product. The posted code was mostly complete, but it need a couple of modifications for error handling. I’m using Kapersky Security, so I updated the $Filter. You can also remark lines 18 and 26 to return all software on system to determine the best filter:
$computerList = "BadHost", $env:COMPUTERNAME
$filter = "security"
$results = foreach($computerName in $computerList) {
try {
$hive = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, $computerName)
$regPathList = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall",
"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
foreach($regPath in $regPathList) {
if($key = $hive.OpenSubKey($regPath)) {
if($subkeyNames = $key.GetSubKeyNames()) {
foreach($subkeyName in $subkeyNames) {
$productKey = $key.OpenSubKey($subkeyName)
$productName = $productKey.GetValue("DisplayName")
$productVersion = $productKey.GetValue("DisplayVersion")
$productComments = $productKey.GetValue("Comments")
if(($productName -match $filter) -or ($productComments -match $filter)) {
[PSCustomObject]@{
Host = $computerName
Product = $productName
Version = $productVersion
Comments = $productComments
}
}
}
}
$key.Close()
}
}
}
catch {
$msg = 'Error occured collecting information from {0}. {1}' -f $computerName, $_
[PSCustomObject]@{
Host = $computerName
Product = $null
Version = $null
Comments = $msg
}
}
}
$results | ft -au
Output:
Host Product Version Comments
---- ------- ------- --------
BadHost Error occured collecting information from BadHost. Exception calling "OpenRemoteBaseKey" with "2" argument(s): "The network path was not found....
DESKTOP-12345 Kaspersky Internet Security 19.0.0.1088
DESKTOP-12345 Kaspersky Internet Security 19.0.0.1088
sasha
November 17, 2019, 3:43am
4
hi Kiran, i ran this script in PowerShell, there was few errors, those i understood were Path errors.
Thank you
sasha
November 17, 2019, 3:45am
5
Thank you, Rob Simmers
I’ll try it