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
For anyone who has the same problem, we still have it from time to time.
I've been able to narrow it down to some kind of change or service restart on the vCenter side.
It can be solved by restarting the Horizon View Connection server service on the connection server we are running the script against.
Just want to let you know that is has been solved, however, I'm still waiting on an answer form our vCenter experts about what they've done to solve this...
Answer from our vCenter experts: we didn't do anything...
But the same problem is back today.
I also noticed the same/similar message in the Horizon Admin/Console: Could not list datastores from VC
I cannot choose a new snapshot or parent VM for a desktop pool, because apparently I don't have access to the datastores anymore...
Any ideas?
Thanks,
Michiel.
For anyone who has the same problem, we still have it from time to time.
I've been able to narrow it down to some kind of change or service restart on the vCenter side.
It can be solved by restarting the Horizon View Connection server service on the connection server we are running the script against.