Add-PIValue and digital states

Discussion created by rdavin Employee on Aug 1, 2013
Latest reply on Dec 16, 2013 by mhamel

Some co-workers are working on Powershell scripts for building out a PI server, including scripts for post-server install.  Some of our post-server install tasks are:

  1. Creating archive files
  2. Renaming System digital state '?1' to 'Not Measured'
  3. Creating a few Float32 PI Points
  4. Assign the 'Not Measured' state at 1/1/2000 to those  points

There are more tasks not mentioned for brevity.  Basically they can accomplish the 1st three tasks easily.  We've hit a brick wall with the last one.  Here's my pain points with my limited knowledge with Add-PIValue:

  • I can successfully create a digital state object for our 'Not Measured' state, but cannot assign it using Add-PIValue.  Error: Add-PIValue : Unable to cast object of type 'OSIsoft.SMT.PIDigitalState' to type 'System.IConvertible'.
  • If created in PI-SMT, I can read a PIValue using Get-PIValue but it will not let me assign it with Add-PIValue with same error as above.
  • I cannot assign a text string of "Not Measured" to a Float32.  Error message: Add-PIValue : Input string was not in correct format.  I tried this with standard system state of "No Result" for same error.
  • If I have a digital point, I can assign a value using Add-PIValue but only if the -Value is a text string or an integer code.
  • I cannot assign a digital state object to a digital point using Add-PIValue.
  • Lastly there is not -switch to control whether to replace duplicates or not.  Hence it becomes very easy to write multiple values to the same event. 

Any suggested work arounds with Powershell?