DennieTidwell
Enthusiast
Enthusiast

Get-VM Exception has been thrown by the target of an invocation.

Jump to solution

Get-VM doesn't show actual VMs in cluster. Web Client clearly shows 89 VMs powered up and running.

VM count is off. Correct number is 89 VMs in this cluster. Causes issues on performance reports as only subset is used for calculations.

Two resource groups, but subset contains VMs from both (just not all).

Checked PS, .Net, PwrCli versions

Tried this on several servers/workstations.

PS C:\> get-cluster clustername | get-vm | measure

get-vm : 3/15/2018 7:14:39 AM Get-VM Exception has been thrown by the target of an invocation.

At line:1 char:23

+ get-cluster clustername | get-vm | measure

+                       ~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-VM], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

Count    : 47

Average  :

Sum      :

Maximum  :

Minimum  :

Property :

PowerCLI Version

----------------

   VMware PowerCLI 6.5 Release 1 build 4624819

---------------

Component Versions

---------------

   VMware Cis Core PowerCLI Component 6.5 build 4624453

   VMware VimAutomation Core PowerCLI Component 6.5 build 4624450

   VMWare ImageBuilder PowerCLI Component 6.5 build 4561891

   VMWare AutoDeploy PowerCLI Component 6.5 build 4561891

   VMware Vds PowerCLI Component 6.5 build 4624695

   VMware Cloud PowerCLI Component 6.5 build 4624821

   VMware HA PowerCLI Component 6.0 build 4525225

   VMware HorizonView PowerCLI Component 7.0.2 build 4596620

   VMware Licensing PowerCLI Component 6.5 build 4624822

   VMware PCloud PowerCLI Component 6.5 build 4624825

   VMware Storage PowerCLI Component 6.5 build 4624820

   VMware vROps PowerCLI Component 6.5 build 4624824

   VMware vSphere Update Manager PowerCLI 6.5 build 4540462

PS C:\> $psversiontable

Name                           Value                                                                                                                                       

----                           -----                                                                                                                                        

PSVersion                      5.1.14409.1012                                                                                                                            

PSEdition                      Desktop                                                                                                                                    

PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                      

BuildVersion                   10.0.14409.1012                                                                                                                              

CLRVersion                     4.0.30319.42000                                                                                                                              

WSManStackVersion              3.0                                                                                                                                          

PSRemotingProtocolVersion      2.3                                                                                                                                          

SerializationVersion           1.1.0.1                                                                                                                                      

PS C:\> Get-ChildItem "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\" | Get-ItemPropertyValue -Name Release

460805

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Do you have the possibility to uninstall/install PowerCLI on that station?

Or even better try the same from another station, preferable with a fresh PowerCLI installation?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
11 Replies
LucD
Leadership
Leadership

Looks like there might be something dishy with that cluster.

What do the following lines say?

Get-Cluster clustername

Get-Cluster clustername | Get-VM | Measure-Object

Get-Cluster clustername | Get-VM -ErrorAction SilentlyContinue | Measure-Object

Get-Cluster clustername | Get-VMhOST | Measure-Object

(Get-Cluster clustername | Get-VMHost).ExtensionData.Vm.Count


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
DennieTidwell
Enthusiast
Enthusiast

Thank you for your response, Luc.

pastedImage_0.png

There are 13 datacenters on this vC. Results do not change if I preface commands with get-datacenter.

Today I am getting different but still unsatisfactory results. Results when run against full vC are accurate on vm count.

C:\> get-vm | measure

Count    : 268

Average  :

Sum      :

Maximum  :

Minimum  :

Property :

get-cluster clustername | get-vm | measure

get-cluster : Check the spelling of the cluster name. Otherwise, there might be a problem with your network. Make

sure the cluster nodes are turned on and connected to the network or contact your network administrator.

    The RPC server is unavailable

At line:1 char:1

+ get-cluster garland | get-vm | measure

+ ~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : ConnectionError: (:) [Get-Cluster], ClusterCmdletException

    + FullyQualifiedErrorId : ClusterRpcConnection,Microsoft.FailoverClusters.PowerShell.GetClusterCommand

Count    : 0

Average  :

Sum      :

Maximum  :

Minimum  :

Property :

Results of running commands you suggested were all the same. Same results against other clusters.

get-cluster : Check the spelling of the cluster name. Otherwise, there might be a problem with your network. Make

sure the cluster nodes are turned on and connected to the network or contact your network administrator.

    The RPC server is unavailable

At line:1 char:1

+ get-cluster garland | get-vm | measure

+ ~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : ConnectionError: (:) [Get-Cluster], ClusterCmdletException

    + FullyQualifiedErrorId : ClusterRpcConnection,Microsoft.FailoverClusters.PowerShell.GetClusterCommand

Strangely, My vCheck reports are accurate - I guess since get-vm from root is good.

There is an update for this vC available.

0 Kudos
LucD
Leadership
Leadership

What type and version of vCenter (or VCSA) are you using?

Are you connected to the vCenter? What is in $global:defaultviservers?
Are you sure you are executing the PowerCLI Get-Cluster cmdlet?There is also a Get-Cluster that comes with Hyper-V.

What does this return?

VMware.VimAutomation.Core\Get-Cluster -Name clustername


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
DennieTidwell
Enthusiast
Enthusiast

On a server 2012 R2

PS C:\> get-cluster clustername | get-vm | measure

get-vm : 3/15/2018 2:15:27 PM Get-VM Exception has been thrown by the target of an invocation.

At line:1 char:23

+ get-cluster clustername | get-vm | measure

+                       ~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-VM], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

Count    : 48

Average  :

Sum      :

Maximum  :

Minimum  :

Property :

PS C:\> get-cluster clustername

Name                           HAEnabled  HAFailover DrsEnabled DrsAutomationLevel 

                                          Level                                    

----                           ---------  ---------- ---------- ------------------ 

Clustername                       True       1          True       FullyAutomated     

PS C:\> get-cluster clustername | get-vm | measure-object

get-vm : 3/15/2018 2:17:02 PM Get-VM Exception has been thrown by the target of an invocation.

At line:1 char:23

+ get-cluster garland | get-vm | measure-object

+                       ~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-VM], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

Count    : 48

Average  :

Sum      :

Maximum  :

Minimum  :

Property :

PS C:\> get-cluster clustername | get-vm -ErrorAction SilentlyContinue | measure-object

Count    : 48

Average  :

Sum      :

Maximum  :

Minimum  :

Property :

PS C:\> get-cluster clustername | get-vmhost | measure-object

Count    : 3

Average  :

Sum      :

Maximum  :

Minimum  :

Property :

PS C:\> (get-cluster clustername | get-vmhost).ExtensionData.vm.count

91

PS C:\>

0 Kudos
LucD
Leadership
Leadership

And this is all done from the same station?

I would advise to remove PowerCLI completely from that station, and then reinstall it.

Or even better try from another station with a fresh PowerCLI installation.

Btw,try to go for the latest PowerCLI 10.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
DennieTidwell
Enthusiast
Enthusiast

pastedImage_0.png

Yes, $DefaultVIserver is target

Reconnected with same results

0 Kudos
DennieTidwell
Enthusiast
Enthusiast

C:\> VMware.VimAutomation.Core\Get-Cluster -Name clustername

Name                           HAEnabled  HAFailover DrsEnabled DrsAutomationLevel 

                                          Level                                    

----                           ---------  ---------- ---------- ------------------ 

Clustername                       True       1          True       FullyAutomated

0 Kudos
LucD
Leadership
Leadership

So that seems to be ok.

Can you now try

VMware.VimAutomation.Core\Get-Cluster -Name clustername |

Get-VM |

Measure-Object


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
DennieTidwell
Enthusiast
Enthusiast

PS C:\> VMware.VimAutomation.Core\Get-Cluster -Name clustername | Get-VM | Measure-Object

Get-VM : 3/15/2018 3:13:06 PM Get-VM Exception has been thrown by the target of an invocation.

At line:1 char:55

+ VMware.VimAutomation.Core\Get-Cluster -Name clustername | Get-VM | Measur ...

+                                                       ~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-VM], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

Count    : 48

Average  :

Sum      :

Maximum  :

Minimum  :

Property :

90 VMs actually in cluster today

0 Kudos
LucD
Leadership
Leadership

Do you have the possibility to uninstall/install PowerCLI on that station?

Or even better try the same from another station, preferable with a fresh PowerCLI installation?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
DennieTidwell
Enthusiast
Enthusiast

A complete uninstall including deleting all modules in vmware folders and then reinstall corrected this issue.

0 Kudos