abars

powershell  SDK  Updatevalues

Discussion created by abars on Nov 19, 2019

I am newbie  to powershell and PI SDK

 

I need to backfill some data into PI via a powershell script using the SDK

 

I am struggling with the UpdateValues.Why does the $pipoint.UpdateValue (line 15) work,

 

but the $pipoint.UpdateValues (line 20) fail?  (With error message "Cannot find an overload for "UpdateValues" and the argument count: "2" ?

 

Any help is appreciated.

 

 

Why does the 

 

1 $Tags | Foreach {

2 $pipoint = [OSIsoft.AF.PI.PIPoint]::FindPIPoint($piServer,$_)

3 $TagVar = Get-Variable -Name $_

4 $TimeStamps = $TagVar.Value.Time
5 $Values = $TagVar.Value.Value
6 $QualFlags = $TagVar.Value.Quality

7
8 for ($i=0;$i -lt $TimeStamps.Count;$i++) {

9 $pitime = New-Object OSIsoft.AF.Time.AFTime($TimeStamps[$i])

10 $pivalue = New-Object OSIsoft.AF.Asset.AFValue($Values[$i],$pitime)

11 if ($QualFlags[0] -ne 0) { # If Bad quality
12 $pivalue.IsGood = False
13 }

14 $pivalues += $pivalue

15 $pipoint.UpdateValue($pivalue,1) # 0 Replace with substitute flag, 1 Insert, 2 Noreplace, 3 Replace Only, 5 Insert No  Compress, 6 Remove

17
18 } # End For

19

20 $pipoint.UpdateValues($pivalues,1) # 0 Replace with substitute flag, 1 Insert, 2 Noreplace, 3 Replace Only, 5 Insert No Compress, 6 Remove

21

22
23 } # End For each tags

Outcomes