1 Reply Latest reply on May 16, 2018 3:17 PM by gregor Branched from an earlier discussion.

    OSIsoft.PowerShell: How to get the points created within the past 100 days?

    DivyaGowda

      Hello,

       

      Is there a powershell script to find tags created in past 100 days.

       

      am using the below command it is thorowing any output.

       

      $conn = Connect-PIDataArchive -PIDataArchiveMachineName  PIservername

      Get-PIPoint -Attributes * -WhereClause "creationdate:=*-500d" -Connection $conn

       

      Regards,

      Divya

        • Re: OSIsoft.PowerShell: How to get the points created within the past 100 days?
          gregor

          Hello Divya,

           

          Please accept our apologies for the late response. You posted your question to this other question which already had an answer marked as the correct one. It's not that we didn't want to answer your question but we do a lot easier if you create a new question instead of posting to a thread which is already considered complete.

           

          OSIsoft.PowerShell is a bit picky on date strings. It doesn't like PI Time notations like 't' for today or relative references like '*-100d'. Instead it expects a string containing a representation which can easily be parsed as DateTime object. Other than this you've been almost there and I really like your idea.

           

          I am not too happy with the script as it looks kind of ugly to me. I found it pretty useful to reset the result variable ($pts) to null between different runs as otherwise you may see the result of a previous run and do not recognize the latest modification broke the script.

           

          $piHost = 'GB-PIDA1'
          $attr = 'creationdate'
          $conn = Connect-PIDataArchive -PIDataArchiveMachineName $piHost
          $now = Get-Date
          $qStart = $now.AddDays(-100).ToString('dd-MMM-yyyy')
          $qString = $attr+':>'+$qStart
          $qString
          $pts = $null
          $pts = Get-PIPoint -Attributes $attr -WhereClause $qString -Connection $conn
          $pts.Count
          foreach ($pt in $pts)
          {
              $pt.Point.Name+': '+$pt.Attributes.Item($attr)
          }
          
          1 of 1 people found this helpful