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

PI Powershell

GetPIValue Class

  • Last UpdatedDec 15, 2025
  • 6 minute read
GetPIValue Class

Get a PI Value at a specified time or for a specified time range.

The Get-PIValue cmdlet will get a value or values from the specified PI Data Archive. The time can be set as a specific time, a range, or a set number of values starting at a certain time in either direction (forward in time or backwards in time). Run "Get-Help Get-PIValue -Examples" to see usage.

The PI Point to get a value for can be specified by PointName, PointID, or by the result of the Get-PIPoint cmdlet. Run "Get-Help Get-PIPoint" for more information.

The Get-PIValue cmdlet can retrieve Interpolated Events by using the -InterpolatedEvents flag. Run "Get-Help Get-PIValue -Examples" to see usage.

Note that all timestamps returned via this cmdlet are in UTC time, and not automatically converted to the client machine's local time zone.

Inheritance Hierarchy

SystemObject
  InternalCommand
    Cmdlet
      PSCmdlet
        OSIsoft.PowerShellOSICmdletBase
          OSIsoft.PowerShellGetPIValue

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

Syntax

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

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

The GetPIValue type exposes the following members.

Constructors

  NameDescription
Public method
GetPIValue

Properties

  NameDescription
Public property
ArchiveMode

The value retrieval mode with which to retrieve the value/values.

If not specified, "Interpolated" is the default retrieval mode.

Public property
Connection

Specifies which connection to a PI Data Archive to use.

Public property
Count

The number of values to return when retrieving a specific number of values from a StartTime. The values are returned forward in time from the StartTime by default. To reverse the order, use the -Reverse parameter.

Public property
EndTime

The EndTime to use when retrieving a range of values.

Public property
InterpolatedEvents

Specifices if Interpolated Events should be returned.

Public property
MaxCount

The maximum number of values to retrieve when retrieving values by time range (with StartTime and EndTime).

Public property
Outside

Include the first value outside the time range specified.

Public property
PIPoint

The PIPoint object for which to retrieve a value/values.

Public property
PointId

The PointID of the PI Point for which to retrieve a value/values.

Public property
PointName

The name of the PI Point for which to retrieve a value/values.

Public property
Reverse

Reverses the order of the number of values retrieved using -StartTime and -Count parameters. Causes values to be returned backwards in time from the -StartTime.

Public property
StartTime

The StartTime to use when retrieving a range of values.

Public property
Stream

The Stream object for which to retrieve a value/values.

Public property
Time

Time for which to retrieve a value

Examples

Get-PIValue -PointName Sinusoid -Time "5-Aug-2017 10:00:00" -ArchiveMode Interpolated -Connection $con

Get PI Value at a Specified Time Using PointName:

This example will retrieve an interpolated value at 10:00am on Aug 5, 2017 for the PI Point "Sinusoid". Valid options for -ArchiveMode are: Previous, Auto, Before, Interpolated, After, Next. Interpolated is the default ArchiveMode.

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

Examples

Get-PIValue -PIPoint (Get-PIPoint -Name Sinusoid -Connection $con) -Time "5-Aug-2017 10:00:00" -ArchiveMode Interpolated

Get PI Value at a Specified Time Using PIPoint Object:

This example does the same thing as the first example, except that the PIPoint object is supplied via Get-PIPoint instead of specifying the PointName string.

Examples

Get-PIValue -PointName Sinusoid -StartTime "5-Aug-2017 10:00:00" -Count 10 -Reverse -Connection $con

Get Number of Events From a StartTime:

This example will retrieve the 10 events prior to the specified StartTime of "5-Aug-2017 10:00:00" for the PointName "Sinusoid".

If -Reverse is not specified, events after the StartTime are returned. If -Reverse is specified (as in this case) events prior to the StartTime are returned.

Instead of -PointName, either -PointID or -PIPoint can also be used to define the PI Point for which to retrieve the values.

Examples

Get-PIValue -PIPoint (Get-PIPoint -Name Sinusoid -Connection $con) -StartTime "5-Aug-2017 10:00:00" -EndTime "6-Aug-2017 10:00:00" -MaxCount 1000

Get PI Values in a Time Range:

This example uses -PIPoint and Get-PIPoint to retrieve values for Sinusoid between the 5th and 6th of August, 2017 at 10:00:00. -MaxCount is used in this case to protect against querying too many values, and will only return up to 1000 values if more than 1000 values exist in the time range.

If -MaxCount is not specified, then all values in the time range will be returned.

Examples

Get-PIValue -PIPoint (Get-PIPoint -Name Sinusoid -Connection $con) -StartTime (ConvertFrom-AFRelativeTime -RelativeTime "*-4h") -EndTime (ConvertFrom-AFRelativeTime -RelativeTime "*")

Get PI Values in a Time Range Using ConvertFrom-AFRelativeTime:

This example uses -PIPoint and Get-PIPoint to retrieve values for Sinusoid for the last 4 hours using ConvertFrom-AFRelativeTime.

Run "Get-Help ConvertFrom-AFRelativeTime" for more details.

Examples

Get-PIValue -PIPoint (Get-PIPoint -Name Sinusoid -Connection $con) -Time (ConvertFrom-AFRelativeTime -RelativeTime "*") -ArchiveMode Previous

Get Snapshot Value for a Tag:

This example will get the snapshot value for a tag. Note that -ArchiveMode Previous must be used with a relative time of "*", otherwise an interpolated value (default) will be returned, which is not the correct snapshot value.

Examples

Get-PIValue -InterpolatedEvents -PIPoint (Get-PIPoint -Name Sinusoid -Connection $con) -StartTime (ConvertFrom-AFRelativeTime -RelativeTime "y") -EndTime (ConvertFrom-AFRelativeTime -RelativeTime "t") -MaxCount 10

Get Snapshot Value for a Tag:

This example will get the interpolated events for the specified PI Point. Note that -InterpolatedEvents must be used to get interpolated events.

See Also

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