2 Replies Latest reply on Nov 12, 2019 1:37 AM by Mickeybyte2

    VMWare View API - VirtualCenterHealth - Session is not authenticated

    Mickeybyte2 Novice

      Hi all,

       

      To monitor our Horizon infrastructure with PRTG, I created some custom made scripts that use powerCLI and the ViewAPI. Suddenly, yesterday some of them stopped working and I have no idea what caused it, nor how to solve it. I'll list the script and the output. Hopefully someone can help me out? (the script output has been limited for readabliity)

       

      Thanks a lot for any ideas.

      Michiel.

       

       

      Script:

      # import necessary modules

      Import-Module VMware.VimAutomation.Core

      Import-Module VMware.VimAutomation.HorizonView

      # connect to Horizon View Connection Server

      $con = Connect-HVServer -Server "<view connection server>"  

      #get Connection server information  

      Write-host "**************************"

      Write-host "Get Connection Server information"

      $viewAPI = ""

      $viewAPI = $Global:DefaultHVServers.ExtensionData.ConnectionServerHealth.ConnectionserverHealth_List()

      $viewAPI

      write-host ""

      #get VCenter information

      Write-host "**************************"

      Write-host "Get VirtualCenter information"

      $viewAPI = ""

      $viewAPI = $Global:DefaultHVServers.ExtensionData.VirtualCenter.VirtualCenter_List()

      $viewAPI

      write-host ""

      #all commands above work fine without problems

       

       

      #following commands give an authentication error

      #get VirtualCenterHealth_List information

      Write-host "**************************"

      Write-host "Get VirtualCenter Health information"

      $viewAPI = ""

      $viewAPI = $Global:DefaultHVServers.ExtensionData.VirtualCenterHealth.VirtualCenterHealth_List()

      $viewAPI

      write-host ""

      #get ESX Hosts from vCenters

      Write-host "**************************"

      Write-host "Get ESX Hosts information"

      $viewAPI = ""

      $viewAPI = $Global:DefaultHVServers.ExtensionData.VirtualCenterHealth.VirtualCenterHealth_List().HostData

      $viewAPI

      write-host ""

      #get Datastores from vCenters

      Write-host "**************************"

      Write-host "Get Datastores information"

      $viewAPI = ""

      $viewAPI = $Global:DefaultHVServers.ExtensionData.VirtualCenterHealth.VirtualCenterHealth_List().DataStoreData

      $viewAPI

      write-host ""

      Disconnect-HVServer $con

       

      Script output:

      **************************

      Get Connection Server information

      Id                 : VMware.Hv.ConnectionServerId

      Name               : VIEWCONN002

      Status             : OK

      Version            : 7.9.0

      Build              : 13956742

      ...<cropped output for readablity>...

      DefaultCertificate : True

      CertificateHealth  : VMware.Hv.CertificateHealthData

       

      **************************

      Get VirtualCenter information

      Id                         : VMware.Hv.VirtualCenterId

      ServerSpec                 : VMware.Hv.ServerSpec

      Description                :

      DisplayName                :

      Version                    : 6.5.0

      ...<cropped output for readablity>...

      SeSparseReclamationEnabled : False

      Enabled                    : True

      VmcDeployment              : False

      IsDeletable                : False

       

      **************************

      Get VirtualCenter Health information

      Exception calling "VirtualCenterHealth_List" with "0" argument(s): "ExceptionType : VMware.Hv.UnexpectedFault

      ErrorMessage : Could not list datastores from VC

      CauseString : com.vmware.vdi.adamwrapper.exceptions.VCServerException: The session is not authenticated.

      CauseStackTrace : System.String[]

      ErrorCode :

      ErrorAttributes : "

      At C:\Users\<username>\Documents\WindowsPowerShell\HorizonViewTest.ps1:27 char:1

      + $viewAPI = $Global:DefaultHVServers.ExtensionData.VirtualCenterHealth ...

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

          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

          + FullyQualifiedErrorId : VimException

       

      **************************

      Get ESX Hosts information

      Exception calling "VirtualCenterHealth_List" with "0" argument(s): "ExceptionType : VMware.Hv.UnexpectedFault

      ErrorMessage : Could not list datastores from VC

      CauseString : com.vmware.vdi.adamwrapper.exceptions.VCServerException: The session is not authenticated.

      CauseStackTrace : System.String[]

      ErrorCode :

      ErrorAttributes : "

      At C:\Users\<username>\Documents\WindowsPowerShell\HorizonViewTest.ps1:34 char:1

      + $viewAPI = $Global:DefaultHVServers.ExtensionData.VirtualCenterHealth ...

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

          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

          + FullyQualifiedErrorId : VimException

       

      **************************

      Get Datastores information

      Exception calling "VirtualCenterHealth_List" with "0" argument(s): "ExceptionType : VMware.Hv.UnexpectedFault

      ErrorMessage : Could not list datastores from VC

      CauseString : com.vmware.vdi.adamwrapper.exceptions.VCServerException: The session is not authenticated.

      CauseStackTrace : System.String[]

      ErrorCode :

      ErrorAttributes : "

      At C:\Users\<username>\Documents\WindowsPowerShell\HorizonViewTest.ps1:41 char:1

      + $viewAPI = $Global:DefaultHVServers.ExtensionData.VirtualCenterHealth ...

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

          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

          + FullyQualifiedErrorId : VimException