VMware Cloud Community
mattkr
Contributor
Contributor

VMware determine physical ESX host from guest VM

Anyway to deterine what ESX host a VM is running on from withing the guest OS itself. Maybe using a vmware-service.exe command? Or do I have to rely on SDK command to do it?

0 Kudos
2 Replies
RvdNieuwendijk
Leadership
Leadership

If the guest is running Microsoft Windows you can use VMware vSphere PowerCLI to retrieve the host with the next PowerCLI script:

Connect-VIServer YourvCenterServerName -Credential (Get-Credential)
$Computername = (Get-ChildItem env:COMPUTERNAME).Value
(Get-VM -Name $ComputerName | Get-VMHost).Name
Disconnect-VIServer -Confirm:$false

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
pascuzzi
Contributor
Contributor

This script only works if the VM name is the same as the name in the virtual center server and that you enforce that names are unique

0 Kudos