I am currently running 6.5a (Build 4944578) with ESXi 6.0u2 hosts. I updated the PowerCLI on my Windows 7 computer to 6.5R1. At that point in time all my scripts were working OK.
I then made some changes to my HA cluster. Specifically I changed the HA restart priority on my VMs. As soon as I reconfigured the cluster my scripts began to fail. After a significant amount of debugging, it turned out that my VCSA was the culprit.
With the HA restart priority set to "high", I can run the command "get-vmhost xxxxx.xx.xxxxx.xxx | get-vm" and I get a list of the VMs running on that host including my VCSA.
If I reconfigure the HA restart priority to "highest", I get the following output to the same command:
C:\local\scripts> get-vmhost xxxxx.xx.xxxxx.xxx | get-vm
Name PowerState Num CPUs MemoryGB
---- ---------- -------- --------
vclab PoweredOn 2 10.000
get-vm : 3/13/2017 1:10:08 PM Get-VM Exception has been thrown by the target of an invocation.
At line:1 char:34
+ get-vmhost xxxxx.xx.xxxxx.xxx | get-vm
+ ~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-VM], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM
BTW, the command "get-vm XXXX" (where XXXX is the name of my VCSA) does not return an error. It is only in conjunction with the results of the get-vmhost command are piped to it.
If I reset the restart priority to "high" everything works again.