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

PI Powershell

GetPIMessage Class

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

Get PI Messages from a PI Data Archive

The Get-PIMessage cmdlet gets message logs from a specified PI Data Archive.

The connection parameter specifies which connection to a PI Data Archive to use.

Inheritance Hierarchy

SystemObject
  InternalCommand
    Cmdlet
      PSCmdlet
        OSIsoft.PowerShellOSICmdletBase
          OSIsoft.PowerShellOSICmdletBaseWithConnection
            OSIsoft.PowerShellGetPIMessage

Namespace:  OSIsoft.PowerShell
Assembly:  OSIsoft.PowerShell (in OSIsoft.PowerShell.dll) Version: 3.1.1.0 (3.1.1.466)

Syntax

[CmdletAttribute("Get", "PIMessage", SupportsShouldProcess = true, 
	DefaultParameterSetName = "Local")]
public class GetPIMessage : OSICmdletBaseWithConnection
<CmdletAttribute("Get", "PIMessage", SupportsShouldProcess := true, 
	DefaultParameterSetName := "Local")>
Public Class GetPIMessage
	Inherits OSICmdletBaseWithConnection

Dim instance As GetPIMessage
[CmdletAttribute(L"Get", L"PIMessage", SupportsShouldProcess = true, 
	DefaultParameterSetName = L"Local")]
public ref class GetPIMessage : public OSICmdletBaseWithConnection
[<CmdletAttribute("Get", "PIMessage", SupportsShouldProcess = true, 
	DefaultParameterSetName = "Local")>]
type GetPIMessage =  
    class
        inherit OSICmdletBaseWithConnection
    end

The GetPIMessage type exposes the following members.

Constructors

  NameDescription
Public method
GetPIMessage

Properties

  NameDescription
Public property
Category

Category mask to search for

Public property
Connection

Connection to a PI Data Archive from which to get the message(s)

(Overrides OSICmdletBaseWithConnectionConnection.)
Public property
Count

Maximum number of messages to retrieve

Public property
EndTime

End time for which to retrieve messages

Public property
Id

Message ID to search for. Multiple Message IDs can be searched by specifying a comma separated list

Public property
Message

Message string mask to search for

Public property
OriginatingHost

Originating hostname of the message to search for

Public property
OriginatingOSUser

Originating OS User of the message to search for

Public property
OriginatingPIUser

Originating PI User of the message to search for

Public property
Priority

Message priority to search for

Public property
ProcessHost

Hostname of the machine running the process that issued the message to search for

Public property
ProcessId

ProcessID of ProgramName to search for

Public property
ProcessOSUser

OS User under which the process issuing the message runs to search for

Public property
ProcessPIUser

PI User Identity of the process issues the message to search for

Public property
Program

Program mask to search for

Public property
SeverityType

Message severity level to retrieve. Severity levels are:

"Debug" -> "Informational" -> "Warning" -> "Error" -> "Critical"

Public property
Source1

Source1 mask to search for

Public property
Source2

Source2 mask to search for

Public property
Source3

Source3 mask to search for

Public property
SourceAny

Source mask for any source field to search for (includes Source1, Source2, and Source3)

Public property
StartTime

Start time for which to retrieve messages

Examples

Get-PIMessage -StartTime (ConvertFrom-AFRelativeTime -RelativeTime *-2h) -EndTime (ConvertFrom-AFRelativeTime -RelativeTime *) -Connection $con

Where:

$con = Connect-PIDataArchive -PIDataArchiveMachineName "PISRV1"

Retrieves all PI Messages from the "PISRV1" PI Data Archive server for the last two hours.

Run "Get-Help ConvertFrom-AFRelativeTime -Full" for more information on using the ConvertFrom-AFRelativeTime cmdlet.

Examples

Get-PIMessage -StartTime "5-Apr-2017 12:00:00" -EndTime "5-Apr-2017 16:00:00" -Count 100 -SeverityType Warning -Program piarchss -Connection $con

Where:

$con = Connect-PIDataArchive -PIDataArchiveMachineName "PISRV1"

This example will retrieve the first 100 messages during the time range "5-Apr-2017 12:00:00" to "5-Apr-2017 16:00:00" with severity of "Warning" or greater, for the program name piarchss (PI Archive Subsystem).

The severity level parameter indicates the minimum severity level of message to retrieve. Severities are ranked as follows:

Debug < Informational < Warning < Error < Critical

Therefore, a specified severity level of "Warning" will only show messages with severity level of Warning, Error, or Critical.

Examples

Get-PIMessage -StartTime "8-Jan-2017 08:00:00" -EndTime "8-Jan-2017 12:00:00" -Message "*PostEvent Failed*" -Connection $con

Where:

$con = Connect-PIDataArchive -PIDataArchiveMachineName "PISRV1"

This example will retrieve messages during the time range "8-Jan-2017 08:00:00" to "8-Jan-2017 12:00:00" where the message body contains the string "*PostEvent Failed*" Note that wildcards are allowed. The -Message parameter can be used in conjunction with other filters from the previous example such as -Program, -SeverityType, -Source1, etc.

Examples

Get-PIMessage -StartTime "22-Aug-2017 00:00:00" -EndTime "23-Aug-2017 00:00:00" -ID 7138 -Connection $con

Where:

$con = Connect-PIDataArchive -PIDataArchiveMachineName "PISRV1"

This example will retrieve messages with message ID 7138 during the time range "22-Aug-2017 00:00:00" to "23-Aug-2017 00:00:00" . The message ID of 7138 corresponds to:

Unsuccessful login Error: [-10413] No trust relation for this request

See Also

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