How to get Antivirus product details from multiple servers?

Welcome Forums General PowerShell Q&A How to get Antivirus product details from multiple servers?

Viewing 2 reply threads
  • Author
    Posts
    • #187780
      Participant
      Topics: 1
      Replies: 2
      Points: -41
      Rank: Member

      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.

       

       

       

    • #187837
      Participant
      Topics: 3
      Replies: 137
      Points: 721
      Helping Hand
      Rank: Major Contributor

      Hi Sasha,

      Can you please let us know where did you stick and what is the error?

      Thank you.

      • #188671
        Participant
        Topics: 1
        Replies: 2
        Points: -41
        Rank: Member

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

    • #187954
      Participant
      Topics: 10
      Replies: 1284
      Points: 1,084
      Helping Hand
      Rank: Community Hero

      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
      
      • #188674
        Participant
        Topics: 1
        Replies: 2
        Points: -41
        Rank: Member

        Thank you, Rob Simmers
        I'll try it

Viewing 2 reply threads
  • You must be logged in to reply to this topic.