C# Wrapper - Get PI SDK Logs using Powershell Tools

Blog Post created by pmartin Employee on Jan 11, 2017

I occasionally see people in the Developer's Club requesting information on how to get PI SDK logs (such as information from their PI Data Archive) using the PI AF SDK.  The AF SDK does not provide this functionality and often our go-to response is to use the PowerShell Tools for the PI System. It's a great product but I can understand not wanting to learn how to use Powershell to do something simple such as getting message logs.


To make things easier, I decided to write a quick C# wrapper so that you can leverage these tools without leaving the comfort of .NET .   This is by no means an official solution.  Just something I thought might be helpful.

You can download the project here: GitHub - osipmartin/PowershellLogWrapper: C# Wrapper for Powershell Get-PIMessage to get PI SDK logs.


There are two projects in the solution.

Powershell_Logging: This is the actual library.  When you build the project, it will produce a dll that you can use elsewhere.

ReadPSLog: This is a simple console application that shows how to use one of the functions from the library.


I did just a bare minimum of testing.  If you have issues please feel free to tell me or fork the repository and fix it.


Note: I included the switches that I use regularly when I am getting messages but left out a couple switches that I never use.  Feel free to fork and modify to your hearts content.