3 Replies Latest reply on Jan 8, 2018 8:01 AM by John Messinger Branched from an earlier discussion.

    VBA script for extracting the PI components installed and their versions.

    Niranjan032

      Eugene Lee

      Kenji Hashimoto

      Han Yong Lee

       

      Could you please help me out with this.. I need VBA script for extracting the PI components installed and their versions.

      I have a list of PI servers in which I have to find the PI components installed and their versions.

      I know to connect to the PI servers and pull the tag attributes but not the installed PI components. Please help me!

        • Re: VBA script for extracting the PI components installed and their versions.
          John Messinger

          Hi Niranjan,

           

          This question should really be in it's own new thread. Aside from that, do you need to do this specifically in VBA? This is a fairly simple task to do with PowerShell:

           

          Get-WmiObject -Class Win32_Product |
              Where-Object {$_.Vendor -like 'OSIsoft*'} |
              Select-Object Name, Version |
              Format-Table -AutoSize
          

           

          You can also remote execute this script using the Invoke-Command cmdlet, and passing this script to the ScriptBlock parameter:

           

          Invoke-Command -ComputerName $Server -ScriptBlock {
               Get-WmiObject -Class Win32_Product | 
                   Where-Object {$_.Vendor -like 'OSIsoft*'} | 
                   Select-Object Name, Version | 
                   Format-Table -AutoSize
          }
          

           

          John

          1 of 1 people found this helpful
            • Re: VBA script for extracting the PI components installed and their versions.
              Niranjan032

              Hi John,

               

              I know VBA, So if code is provided I can run it in test environment and check. I'm not aware of PowerShell much.

              Could you please tell me where exactly I need to add my vendor, Server name in the above code?

              Say I have a server called "Server01" and the vendor is "OSIsoft" what should the code look like.

               

              Thanks,

              Niranjan

                • Re: VBA script for extracting the PI components installed and their versions.
                  John Messinger

                  I'm going to suggest that you have a look at the example code on this external blog, as it seems to cover the same functionality using VBA as the previously provided PowerShell script. Your requirement isn't specifically a PI technology related issue other than wanting to programmatically obtain a list of installed OSIsoft products on a server, so I believe this external code example should meet your needs. Note that it still uses WMI, and you should be able to filter the returned list of software (by vendor) by using an appropriate WHERE clause in the objWMIService.ExecQuery method call.

                   

                  Should you wish to explore the ease and flexibility of PowerShell with the previously provided script, note that the first version can be run locally on any server, and will return a list of all installed OSIsoft products. The second version can be used for remote execution - swap the $Server variable with the name of the remote server, or set the variable value to the server name.

                   

                  Personally, I would lean towards the PowerShell option, as the code is much simpler, and doesn't need to be compiled.

                   

                  John

                  1 of 1 people found this helpful