i'm writing a powerCLI script and i'm facing a strange behaviour.

I use connect-VIserver with administrator@vsphere.local account to connect to my VCSA 6.7 U2 server. If i use Get-VM cmdlet without any parameter it returns all VMs without problems. Then i would get a list of VMs on a particular ESXi host. BUT when i launch: Get-VM -Location "esxi server name" it returns only one result (of 25vms present on that host), then error.

PowerCLI C:\> Get-VM -Location $sum

Name                 PowerState Num CPUs MemoryGB
----                 ---------- -------- --------
GIUDECCA             PoweredOn  4        16,000
Get-VM : 05/12/2019 16:07:43    Get-VM          Eccezione generata dalla destina
zione di
una chiamata.
At line:1 char:1
+ Get-VM -Location $sum
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-VM], VimException
    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomatio

As you see in the code i posted i tried to use the parameter with a variable, using Get-VMHost -Name "esxi server name". but same error. What i am doing wrong?

O.S. Windows 7 Powershell 5.1 PowerCLI 6.5


Ok, i found the solution, maybe was an incompatibility between version installed. I opened a Powershell and installed powercli modules from PSGallery. Now it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.