AnsweredAssumed Answered

Identifying tags with duplicate records.

Question asked by BrianKHeritage on Dec 17, 2018
Latest reply on Dec 17, 2018 by BrianKHeritage

We have a situation at site where occasionally duplicate records are created for some of the tags.  The problem is intermittent and doesn't always happen on the same tag every time.  Because this is an intermittent problem, OSISoft has recommended we monitor the tags and get back to them when it happens again.  So to allow us to monitor, I've come up with a Powershell script that will list all the tags on the system and their 11:00:00 value.  If there is more than one value, both are output.  This is the script I wrote:

 

# connect to PI Data Archive by machine name
#$PIServerHost = "OTCENPIDADEV1"
$PIServerHost = "OTCENPIDAPRD1"
$con = Connect-PIDataArchive -PIDataArchiveMachineName $PIServerHost -ErrorAction Stop

if ($con.Connected)
{
    # get a collection of PIPoints matching mask "*CN*"
    $PIPoints = Get-PIPoint -Name *CN* -AllAttributes -Connection $con

    if ($PIPoints -ne $null)
    {
        foreach ($PIPoint in $PIPoints)
        {
            $ProcessTag = $PIPoint
            $ProcessTagName = $ProcessTag.Point.Name
            Write-Output "Now processing $ProcessTagName"
            Get-PIValue -PIPoint $PIPoint -Starttime "17-Dec-2018" -EndTime "18-Dec-2018" | Where-Object { ($_.Timestamp).timeofday -eq "11:00:00"} | Select-Object Timestamp,Value
        }
    }
}

 

And this is an example of the output:

 

Now processing CN_AMB_II_Menor

2018-12-17 11:00:00 AM     0

Now processing CN_AMB_IV_Grave

Now processing CN_AMB_I_Insignificante

Now processing CN_AMB_V_Catastrofico

2018-12-17 11:00:00 AM     0

2018-12-17 11:00:00 AM   25

 

This is good, but I then have to scroll through the listing (almost 5000 tags) looking for any tags with two records.  What I'd like to see is:

 

Now processing CN_AMB_II_Menor

Count: 1

Now processing CN_AMB_IV_Grave

Count: 0

Now processing CN_AMB_I_Insignificante

Count: 0

Now processing CN_AMB_V_Catastrofico

Count: 2

 

Something like this would help because then all I'd need to do is use the find option in Notebook and look for "Count: 2".  Alternatively, something like this would be better:

 

Now processing CN_AMB_II_Menor

Count: Good

Now processing CN_AMB_IV_Grave

Count: Good

Now processing CN_AMB_I_Insignificante

Count: Good

Now processing CN_AMB_V_Catastrofico

Count: Bad

 

This would be ideal, because I'd only need to look for the word "Bad".

 

Any help you folks could give would be greats.  Thanks in advance.

Outcomes