This is already solved here by nicholas1982 and LucD, but I wanted to mention another option: the vNugglets.Utility PowerShell module (of which I am an author) has a cmdlet for getting VMs by VM guest hostname: Get-VNVMByAddress with the -GuestHostname parameter.
Example for a single guest OS hostname:
Get-VNVMByAddress -GuestHostname myguesthostname0
Name GuestHostname MoRef Client
---- ------------- ----- ------
myVMName0 myguesthostname0 VirtualMachine-vm-18927 VMware.Vim.VimClientImpl
Or, for a list of guest OS hostnames:
## iterate through each server name in the file, returning corresponding VMs with given guest OS hostnames
Get-Content C:\scripts\servers.txt | Foreach-Object {Get-VNVMByAddress -GuestHostname $_}
Part of the benefit: that Get-VNVMByAddress cmdlet is using the vCenter SearchIndex object, and can be quicker/more efficient, especially in a larger environment.
And, of course, that module is available in the PowerShellGallery, so getting it is easy with Install-Module or Save-Module.