5 Replies Latest reply on Mar 24, 2017 5:26 PM by LouisSalin

    Get-PIPoint throws an "Object reference not set to an instance of an object" error

    LouisSalin

      Hi everyone,

       

      I've using a quick PowerShell script to get data out of a PI archive and I have recently started getting errors accessing PI Points. Trying to access an existing tag from a connected server results in an error and trying to access a non existing tag doesn't cause any error. This makes me think the issue is inside the SDK. Thank you for any help!

       

      The following output should illustrate my issue:

       

      ------------

       

       

      PS C:\Spark> $MyServer = Connect-PIDataArchive -pidataarchivemachinename <some server> -PIUsername "<some username>"

      PS C:\Spark> $MyServer

       

      Credential              : PIUser: <some username>

      Identity                : <some username>

      Principal               : <some username>

      OperationTimeout        : 00:10:00

      OpenTimeout             : 00:00:10

      Behavior                : ReconnectBehavior: ConnectionPreference: Reconnect; BindingType: Reconnect

      ProtectionLevel         : None

      ServerVersion           : 3.4.405.1198

      CurrentRole             : Name: <some server>; Type: UnSpecified

      Address                 : pi://<some server>/

      Directory               : OSIsoft.PI.Configuration.PISDKRegistryDirectoryProvider

      Service                 : Service: Name = <some server>; Service Id = ce786160-1fa7-4364-8b8e-3186af1f89f0; type = Standalone

      Configuration           : Name <some server>

      LoginMode               : Legacy_Explicit

      OperatingSystemUserName : <domain>\SparkCognition

      SessionID               : 1

      Name                    :

      Connected               : True

      Uid                     : 3bbc3112-5a7c-49ea-a24c-42368c51c792

      DisconnectedByUser      : False

       

      PS C:\Spark> $MyPIPointObject = Get-PIPoint "<some existing tag>" -connection $MyServer

      Get-PIPoint : Object reference not set to an instance of an object.

      At line:1 char:20

      + ... intObject = Get-PIPoint "<some existing tag>" -connecti ...

      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

          + CategoryInfo          : NotSpecified: (:) [Get-PIPoint], NullReferenceException

          + FullyQualifiedErrorId : System.NullReferenceException,OSIsoft.PowerShell.GetPIPoint

       

      PS C:\Spark> Get-PIPoint "<some tag that doesn't exist" -connection $MyServer

      PS C:\Spark>

       

      (doesn't output any error!!)