VMware Cloud Community
COS
Expert
Expert

Using the get-inventoryplus function getting error....

vCenter Appliance version: 6.5 11347054

PowerCLI version:

VMware.Vim 6.7.0.10334489

VMware.VimAutomation.Cis.Core 11.0.0.10335701

VMware.VimAutomation.Common 11.0.0.10334497

VMware.VimAutomation.Core 11.0.0.10336080

VMware.VimAutomation.Sdk 11.0.0.10334495

I've been using the below function...

Get-InventoryPlus - Inventory of all vSphere objects - LucD notes

Haven't used it in a few months but now I am getting the below bunch of errors...

Cannot convert the "System.Object[]" value of type "System.Object[]" to type "VMware.Vim.ManagedEntity".

At line:125 char:11

+           $Object = Get-View -Id $Parent -Property Name,Parent

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

    + CategoryInfo          : InvalidArgument: (:) [], RuntimeException

    + FullyQualifiedErrorId : ConvertToFinalInvalidCastException

Cannot convert the "System.Object[]" value of type "System.Object[]" to type "VMware.Vim.ManagedEntity".

At line:125 char:11

+           $Object = Get-View -Id $Parent -Property Name,Parent

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

    + CategoryInfo          : InvalidArgument: (:) [], RuntimeException

    + FullyQualifiedErrorId : ConvertToFinalInvalidCastException

The errors go on and on.

Any ideas on how to fix?

0 Kudos
3 Replies
LucD
Leadership
Leadership

Are you perhaps connected to more than one vSphere server?

What is in $global:defaultVIServers?


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

0 Kudos
COS
Expert
Expert

When I connected to the old vcenter server I thought I was connected to only one. Turned out I was connected to two. I removed one and it's running now.

This explains why in the new set of vCenter servers this is happening because the vcenter servers are in linked mode.

How can I get this to work with linked mode vcenter servers other than connecting individually?

Thanks

0 Kudos
LucD
Leadership
Leadership

Did you try by using the Server parameter?
You could do for example

Get-InventoryPlus -Server $global:DefaultVIServers[0]


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

0 Kudos