Product: PowerShell Universal Version: 1.5.11
I have written a short endpoint, which gets some data from virtual machines in vCenter (using PowerCLI).
Connect-VIServer vcenter.domain.local $result = get-VM vms* | Select Name,NumCPU,MemoryGB | ConvertTo-Json -Compress New-PSUApiResponse -Body $result -StatusCode 200 -ContentType 'application/json'
On the client side I call the endpoint by Invoke-RestMethod …
The result has 2 elements. The first seems to come from Connect-VIServer, the second is the expected result.
I’ve found a workaround:
Connect-viserver vcenter.domain.local | Out-Null
Is this behavior expected? Is there any documentation what objects are passed by New-PSUApiResponse - in addition to the Body-parameter?