GetPIMessage Class
- Last UpdatedDec 15, 2025
- 5 minute read
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
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
| Name | Description | |
|---|---|---|
| GetPIMessage |
Properties
| Name | Description | |
|---|---|---|
| Category | Category mask to search for | |
| Connection | Connection to a PI Data Archive from which to get the message(s) | |
| Count | Maximum number of messages to retrieve | |
| EndTime | End time for which to retrieve messages | |
| Id | Message ID to search for. Multiple Message IDs can be searched by specifying a comma separated list | |
| Message | Message string mask to search for | |
| OriginatingHost | Originating hostname of the message to search for | |
| OriginatingOSUser | Originating OS User of the message to search for | |
| OriginatingPIUser | Originating PI User of the message to search for | |
| Priority | Message priority to search for | |
| ProcessHost | Hostname of the machine running the process that issued the message to search for | |
| ProcessId | ProcessID of ProgramName to search for | |
| ProcessOSUser | OS User under which the process issuing the message runs to search for | |
| ProcessPIUser | PI User Identity of the process issues the message to search for | |
| Program | Program mask to search for | |
| SeverityType | Message severity level to retrieve. Severity levels are: "Debug" -> "Informational" -> "Warning" -> "Error" -> "Critical" | |
| Source1 | Source1 mask to search for | |
| Source2 | Source2 mask to search for | |
| Source3 | Source3 mask to search for | |
| SourceAny | Source mask for any source field to search for (includes Source1, Source2, and Source3) | |
| StartTime | Start time for which to retrieve messages |
Examples
Get-PIMessage -StartTime (ConvertFrom-AFRelativeTime -RelativeTime *-2h) -EndTime (ConvertFrom-AFRelativeTime -RelativeTime *) -Connection $conWhere:
$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