VMware Cloud Community
Marcel00M
Contributor
Contributor

multiple MoRef ´s for one VM

Hello,

while trying a function from the powercli sub forum I figured out, that I have VM´s with multiple entrys (an example is listed below).

I have only problems when I want to use the function. I believe because of this multilple entrys.

Everethinks else works well. But imho this can not be good and should be fixed.

After deregistering such an VM,  there still was an entry. But only one. The wrong one, I think thats the needless one, which should be removed.

Afte registering the VM again, there where two entrys again.

I think, we have some "corpses" in our VC DB?

Can some one tell me:

How can they occur?

How whe can remove them?

Is it dangerous to remove them?

How whe can find the" right" entry for a VM, without unregistering it?

Thank You very much!

Example

Example is QDEAHX with MoRef : VirtualMachine-vm-498 and VirtualMachine-vm-14888

After an unregistering only the VirtualMachine-vm-14903 left. I think, thats the needless one.

[vSphere PowerCLI] C:\> get-vm QDEAHX

Name                 PowerState Num CPUs Memory (MB)
----                 ---------- -------- -----------
QDEAHX               PoweredOff 1        900

[vSphere PowerCLI] C:\>get_vm_name_test.ps1

Capability           : VMware.Vim.VirtualMachineCapability

Config               : VMware.Vim.VirtualMachineConfigInfo

Layout               : VMware.Vim.VirtualMachineFileLayout

LayoutEx             : VMware.Vim.VirtualMachineFileLayoutEx

Storage              : VMware.Vim.VirtualMachineStorageInfo

EnvironmentBrowser   :

ResourcePool         :

ResourceConfig       : VMware.Vim.ResourceConfigSpec

Runtime              : VMware.Vim.VirtualMachineRuntimeInfo

Guest                : VMware.Vim.GuestInfo

Summary              : VMware.Vim.VirtualMachineSummary

Datastore            : {Datastore-datastore-39}

Network              : {Network-network-69}

Snapshot             :

GuestHeartbeatStatus : gray

Parent               : Folder-group-v14914

CustomValue          : {}

OverallStatus        : green

ConfigStatus         : green

ConfigIssue          : {}

EffectiveRole        : {-1}

Permission           : {}

Name                 : QDEA8U

DisabledMethod       : {MakePrimaryVM_Task, TerminateFaultTolerantVM_Task, ReconfigVM_Task, RelocateVM_Task...}

RecentTask           : {}

DeclaredAlarmState   : {alarm-11.vm-14903, alarm-12.vm-14903, alarm-2.vm-14903, alarm-24.vm-14903...}

TriggeredAlarmState  : {}

AlarmActionsEnabled  : True

Tag                  : {}

Value                : {}

AvailableField       : {}

MoRef                : VirtualMachine-vm-14903

Client               : VMware.Vim.VimClient

Capability           : VMware.Vim.VirtualMachineCapability

Config               : VMware.Vim.VirtualMachineConfigInfo

Layout               : VMware.Vim.VirtualMachineFileLayout

LayoutEx             : VMware.Vim.VirtualMachineFileLayoutEx

Storage              : VMware.Vim.VirtualMachineStorageInfo

EnvironmentBrowser   : EnvironmentBrowser-envbrowser-15027

ResourcePool         : ResourcePool-resgroup-196

ResourceConfig       : VMware.Vim.ResourceConfigSpec

Runtime              : VMware.Vim.VirtualMachineRuntimeInfo

Guest                : VMware.Vim.GuestInfo

Summary              : VMware.Vim.VirtualMachineSummary

Datastore            : {Datastore-datastore-39}

Network              : {Network-network-69}

Snapshot             :

GuestHeartbeatStatus : gray

Parent               : Folder-group-v14857

CustomValue          : {}

OverallStatus        : green

ConfigStatus         : green

ConfigIssue          : {}

EffectiveRole        : {-1}

Permission           : {}

Name                 : QDEA8U

DisabledMethod       : {MakePrimaryVM_Task, TerminateFaultTolerantVM_Task, RevertToCurrentSnapshot_Task, RemoveAllSnapshots_

                       Task...}

RecentTask           : {}

DeclaredAlarmState   : {alarm-11.vm-15027, alarm-12.vm-15027, alarm-2.vm-15027, alarm-24.vm-15027...}

TriggeredAlarmState  : {}

AlarmActionsEnabled  : True

Tag                  : {}

Value                : {}

AvailableField       : {}

MoRef                : VirtualMachine-vm-15027

Client               : VMware.Vim.VimClient

Used function (basedon/modified "remove-hd" function from LucD, Yust to list the multiple entrys)

function getvmentry {
     param($VMname, $Server)

     if(!$Server){
          $server = $defaultVIServer
     }
    
     $vm = Get-View -Server $server -ViewType VirtualMachine -Filter @{"Name"=$VMname}

     foreach($dev in $vm.Config.Hardware.Device){
          if ($dev.DeviceInfo.Label -eq $HDname){
               $key = $dev.Key
               $name = $dev.Backing.FileName
               $disktype = $dev.Backing.GetType().Name
          }
     }

     echo $vm
}


echo "start"
getvmentry QDEA8U "10.229.191.145"

0 Kudos
0 Replies