2 Replies Latest reply on Nov 25, 2016 4:34 PM by gregor

    Get Archive header information using code

    Paurav Joshi

      Hello Folks,

       

      We can get archive header information using pidiag -ahd <archive_name_with_path> ,and I want to take start and end time of archive in text box.

       

      I have PowerShell version 3.0 so as per Getting started guide, so please suggest accordingly.

      I tried in c# following this article, and still trying to succeed in it.

       

      Has anyone tried it in other way or better way?

       

      PI Data Archive : 2015 (3.4.395.64)

       

      Thanks,

      Paurav Joshi

        • Re: Get Archive header information using code
          gregor

          Hi Paurav,

           

          Are you trying to re-invent PI SMT?

           

          To me the Process class in .NET is a convenient way to exchange information with command line tools like piconfig.exe and pidiag.exe

           

          If you prefer the PowerShell approach, OSIsoft.PowerShell module is installed with PI SMT starting with a certain release (sorry, but it again comes back to PI SMT ).

           

          $yourPIServerName = "yourPIServerHostName"
          $yourPI = Connect-PIDataArchive -PIDataArchiveMachineName $yourPIServerName -AuthenticationMethod Trust
          Get-PIArchiveFileInfo -Connection $yourPI
          
            • Re: Get Archive header information using code
              gregor

              Hi Paurav,

               

              Please accept my apologies. Pidiag.exe is the archive offline utility. It requires archives not being actually registered to a running server. PI SMT and the Get-PIArchiveFileInfo PowerShell command expect archives being online, registered to a running PI Data Archive. For this reason, the only option to get an archive header dump from offline archives that remains is pidiag.exe and to do this programmatically, using the .NET Process class appears to be a good choice.