Hello, DTsaliabine-
Ah, I see -- you are not after the guest OS's host name, but rather the name of the VM object. Like Zsoldier said, using an OSCustomizationSpec might be helpful in this situation.
But, as a couple of examples of getting the VM object's name by running a script within the VM, here are a couple of snippets:
## using standard PowerCLI cmdlet, Get-VM (not very fast, esp. in a larger environment)
(Get-VM | ?{$_.ExtensionData.Guest.HostName -eq $env:Computername}).Name
Or, a way that should run faster:
## get the Name property of the .NET View object of the VM where Tools reported the given computer name (the guest's "hostname")
(Get-View -ViewType VirtualMachine -Property Name -Filter @{"Guest.HostName" = "^$($env:Computername)$"}).Name
VMware Tools seem to report the "DNS Name" of the guest OS as its short name when the machine is not on a domain. So, you could use just the short name in a Where-Object clause or as a filter for getting the .NET View object for the corresponding VM in vCenter, and then access the Name property to get the actual VM object's name.
These snippets assume that VMware Tools are running in the VM, that you have PowerShell and PowerCLI on the VM, and some credentials stored there to make the connection to vCenter.