Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

PI Powershell

AddPIValue Class

  • Last UpdatedDec 15, 2025
  • 5 minute read
AddPIValue Class

Add one or more PI Values to a PI Data Archive

The Add-PIValue cmdlet will add one or more PI Values to the specified PI Data Archive. If multiple values are being written, the number of values in the arrays that are passed in must be either 1, or the same number as each other.

Inheritance Hierarchy

SystemObject
  InternalCommand
    Cmdlet
      PSCmdlet
        OSIsoft.PowerShellOSICmdletBase
          OSIsoft.PowerShellAddPIValue

Namespace:  OSIsoft.PowerShell
Assembly:  OSIsoft.PowerShell (in OSIsoft.PowerShell.dll) Version: 2.2.3.0 (2.2.3.952)

Syntax

[CmdletAttribute("Add", "PIValue", DefaultParameterSetName = "PointName", 
	SupportsShouldProcess = true)]
public class AddPIValue : OSICmdletBase
<CmdletAttribute("Add", "PIValue", DefaultParameterSetName := "PointName", 
	SupportsShouldProcess := true)>
Public Class AddPIValue
	Inherits OSICmdletBase

Dim instance As AddPIValue
[CmdletAttribute(L"Add", L"PIValue", DefaultParameterSetName = L"PointName", 
	SupportsShouldProcess = true)]
public ref class AddPIValue : public OSICmdletBase
[<CmdletAttribute("Add", "PIValue", DefaultParameterSetName = "PointName", 
	SupportsShouldProcess = true)>]
type AddPIValue =  
    class
        inherit OSICmdletBase
    end

The AddPIValue type exposes the following members.

Constructors

  NameDescription
Public method
AddPIValue

Properties

  NameDescription
Public property
Buffer

Write the value or values through PI Buffer Subsystem. If an unsupported version of buffering is being used, or buffering is not installed, an error will be returned.

Public property
Connection

Specifies which connection to the PI Data Archive to use.

Public property
IsQuestionable

Specify if the value or values should have the Questionable bit set

Public property
PIPoint

PIPoint object or PIPoint object of PI Point to write to

Public property
PointId

The PointID or PointIDs of the PI Point(s) to write to

Public property
PointName

The name or names of the PI Point(s) to write to

Public property
Stream

Stream object or Stream objects of PI Point to write to

Public property
Time

Time or times to write at

Public property
UseSystemState

Specify if the value or values should use the SYSTEM digital state when writing.

Public property
Value

Value or values to write

Public property
WriteMode

WriteMode or WriteModes to use when writing a value/values. If not specified, "Append" is the default. Valid options are:

NoReplace : Add unless event(s) exist at same time

Append : Add event, regardless of existing events

Replace : Add event, replace if event at same time

ReplaceX : Replace existing event, fail if not event at time

Remove : Remove existing event

AppendX : Same as append with no compression; that is, if this is the snapshot, force into archive

Examples

Add-PIValue -PointName Sinusoid -Time "1-Apr-2017 20:00:00" -Value 100 -WriteMode Append -Connection $con

Add PI Value at a Specified Time Using PointName:

This example will write a value of 100 to the PI Point "Sinusoid" at the time "1-Apr-2017 20:00:00" with the write mode "Append".

The tag can also be specified by Point ID rather than PointName by using -PointID <PointID> parameter in place of -PointName

Valid options for WriteMode are: Append, AppendX, NoReplace, Remove, Replace, ReplaceX

Examples

Add-PIValue -PIPoint (Get-PIValue -Name Sinusoid -Connection $con) -Time "1-Apr-2017 20:00:00" -Value 100 -WriteMode NoReplace

Add PI Value at a Specified Time Using PI Point Object:

This example writes the same value and time as the previous example, however, the PIPoint object is retrieved via Get-PIPoint and the "NoReplace" WriteMode is used.

Run "Get-Help Get-PIPoint" for more information on this cmdlet.

Examples

Add-PIValue -PointName Sinusoid,SinusoidU,CDT158 -Time (ConvertFrom-AFRelativeTime -RelativeTime T+8h) -Value 100 -WriteMode Append -Connection $con

Add PI Value at a Specified Time to Multiple Tags Using PointName:

This example uses ConvertFrom-AFRelativeTime to write a value of 100 at 8:00am to each of the tags listed: Sinusoid, SinusoidU, and CDT158.

Run "Get-Help ConvertFrom-AFRelativeTime" for more information on this cmdlet.

Examples

Add-PIValue (Get-PIPoint -Name Sin* -Connection $con) -Time (ConvertFrom-AFRelativeTime -RelativeTime Y+17h) -Value 100

Add PI Value at a Specified Time For All Tags Matching a TagMask:

This example will write a value of 100 for yesterday at 5:00pm to all PI Points matching the tagmask "Sin*" with the default WriteMode of Append.

Sinusoid, Y+17h (yesterday at 5pm), 100

SinusoidU, Y+17h (yesterday at 5pm), 100

SinusoidTest, Y+17h (yesterday at 5pm), 100

Examples

Add-PIValue -PointName Sinusoid,SinusoidU,CDT158 -Time "1-Apr-2017 20:00:00","3-May-2017 8:00:00","5-Jun-2017 12:00:00" -Value 100,200,300 -WriteMode ReplaceX -Connection $con

Replace PI Value at Multiple Times for Multiple Tags:

This example will write the following values using ReplaceX mode:

Sinusoid, 1-Apr-2017 20:00:00, 100

SinusoidU, 3-May-2017 08:00:00, 200

CDT158, 5-Jun-2017 12:00:00, 300

Note that all arrays for input: PointName, Time, and Value must either contain the same number of entries or 1. In this example, all input arrays have the same number of entries, so all of the first elements are associated with each other, all the second elements are associated with each other, etc.

See Also

TitleResults for “How to create a CRG?”Also Available in