Hi all,
I need your help getting QueryService_Create to work with Horizon 7.
Using PowerCLI under Windows 7, with the following PS version:
pwsh > $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14409.1018
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1018
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
The code fails at the last line with this error:
Exception calling "QueryService_Create" with "2" argument(s): "Object reference not set to an instance of an objectException calling "QueryService_Create" with "2" argument(s): "Object reference not set to an instance of an objectAt PowerShell\Horizon_03.ps1:14 char:1
+ $queryResults = $queyService.QueryService_Create($hvServices, $defn)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : NullReferenceException
Here is the code (I've already used connect-hvserver successfully before the code):
$queyService = New-Object VMware.Hv.QueryServiceService
$defn = New-Object VMware.Hv.QueryDefinition
$defn.queryEntityType = 'FarmSummaryView'
$queryResults = $queyService.QueryService_Create($hvServices, $defn) # This is line 14 in the program
The code fragment is verbatim from this example:
# https://vdc-repo.vmware.com/vmwb-repository/dcr-public/2365e8a2-2a49-40c3-ae46-510d918c2fa1/86751889-022e-47c4-b2b9-8bc2e3fa6d21/queries-landing.html21
Any help would be greatly appreciated.
-Chris