How to get Antivirus product details from multiple servers?

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

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

        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)) {
                                Host = $computerName
                                Product = $productName
                                Version = $productVersion
                                Comments = $productComments

    catch {
        $msg = 'Error occured collecting information from {0}. {1}' -f $computerName, $_

            Host = $computerName
            Product = $null
            Version = $null
            Comments = $msg

$results | ft -au


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                                                                                                                                                   
DESKTOP-12345 Kaspersky Internet Security

hi Kiran, i ran this script in PowerShell, there was few errors, those i understood were Path errors.
Thank you

Thank you, Rob Simmers
I’ll try it