Reply to Message

View discussion in a popup

Replying to:
virtualg_uk
Leadership
Leadership

Efficient way to get host's name from VM (vim.VirtualMachine)

I am trying to find a highly efficient way to get a host's name from a .NET vim.virtualmachine.

I have been successful in getting the MoRef for the VM, then getting all hosts with get-view and simply looping the hosts for one which contains the VM's MoRef but this is highly inefficient when doing it like this for thousands of virtual machines.

I cannot find a property of vim.virtualmachine that contains the ESXi host's name that the VM is running on, nor can I find an efficient function in the documentation.

Note that I am trying to do this as efficiently as possible so I am avoiding the PowerCLI functions where possible and relying on Get-View rather than Get-Host and Get-VM (Although I can use these if there is a smart way to get the information I need efficiently)

Many thanks

 

 


Graham | User Moderator | https://virtualg.uk
Reply
0 Kudos