So yes, you can have a 'script' connect to all ESX hosts to query for the VM...this assumes you have a good naming convention between the VM display name and the guestOS, or if you have VMware Tools installed you can looking at it's hostname or/and IP Address.
The caveat to all this, if you allow a guestOS look this information up, you're basically allowing connectivity from your VMs into your management network which is a big no no from a security perspective. Is it really necessary that you need this information?
You can accomplish this with PowerCLI which might be easier if you're coming from Windows world, but again you'll need to install Powershell and the PowerCLI bindings on your guest.
Another approach to this, is automatically gather the mappings of ESX(i) host -> VMs and maybe dump that once a day/week to say a CIFS/SAMBA/NFS share, and have your guestOS pull this file and figure out which host it's on. This allows a separation of management network and your VMs and still get you the information you're seeking.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
Twitter: @lamw
VMware Code Central - Scripts/Sample code for Developers and Administrators
VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".