4 Replies Latest reply on Jan 18, 2017 1:30 PM by gregor

    Find Bad and Stale Points via PI Powershell

    1CassaBD

      How do I go about Finding Bad and Stale Points in Pi Powershell similiar to PI SMT?

      This way I can go about cleaning up and notifying users about bad and stale points.

        • Re: Find Bad and Stale Points via PI Powershell
          pmartin

          Hi Benjamin,

           

          There's no native way to do this in Powershell.  You would have to loop through each point and do a Get-PIValue call.  This solution does not scale well and will likely be quite slow.

           

          Better solutions would be:

          1) Utitilzing a AF SDK solution from within Powershell

          2) Writing a piconfig script

            • Re: Find Bad and Stale Points via PI Powershell
              asorokina

              And here is a short and sweet example to support the first solution Paul suggested:

               

              $TimeStale = (Get-Date).AddHours(-5)
              
              
              $refToMyAssembly = [reflection.assembly]::loadwithpartialname("OSIsoft.AFSDK")  
              $PIServer = (New-Object OSIsoft.AF.PI.PIServers)["STARK"]
              $Points =  [OSIsoft.AF.PI.PIPoint]::FindPIPoints($PIServer,"*",$null,$null)
              
              
              $PointList = New-Object OSIsoft.AF.PI.PIPointList -ArgumentList $Points
              
              
              $BadAndStaleSnapshots = $PointList.CurrentValue() | Where-Object {$_.Status -eq 'Bad' -or $_.Timestamp -le $TimeStale}
              $BadAndStaleSnapshots
              
              3 of 3 people found this helpful
            • Re: Find Bad and Stale Points via PI Powershell
              Jerome Lefebvre

              To add there are many other ways to monitor for stale tags, here is a slight aging KB that displays several methods to do so: KB00384 - Monitoring Data Freshness or "Stale" tags

               

              To add one more using analysis. To check if a tag has not been updated for more than 5 minutes, you can do something like the following in Analysis.

               

              This has the advantage that you can use the output of something like StaleCheck variable to trigger emails using PI Notifications, among the many other uses of analysis.

              2 of 2 people found this helpful