添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
暗恋学妹的领带  ·  UQ software catalogue ...·  6 天前    · 
绅士的跑步机  ·  标签 - Tokisaki Galaxy·  17 小时前    · 
淡定的鸭蛋  ·  Drivers for PHP 的 ...·  7 小时前    · 
不拘小节的毛衣  ·  python cs端绘图 ...·  11 月前    · 
强健的登山鞋  ·  Android ...·  1 年前    · 
坚韧的南瓜  ·  JavaScript ...·  2 年前    · 
路过的香蕉  ·  【Android】BottomSheetDi ...·  2 年前    · 

Stack Exchange Network

Stack Exchange network consists of 176 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. Visit Stack Exchange

Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.

Sign up to join this community

I looked and looked but probably overlooked . I have a vsphere cloud with over 300 virtual machines. Each machine name as it appears in the vsphere client is actually the hostname of each machine (I have done this manually). Those machines sometimes have to change their hostname. At this time I hope there is a way to obtain/get/read the guest machine name from the machine itself, and then if there is a mismatch, then I'll know and modify the machine name when needed.

So, vmware-toolbox-cmd or other tool (from the linux open-vm-tools ) can retrieve that info, the machine name ?

Let's take an example. I have a vm machine with it;s hostname a22.test.com I can ssh onto that machine. But on the vsphere it's name is b34.test2.com or some other name. And I have 300+ machines in this mismatched state. A vm name does not correspond to the hostname .

Do you have VMware Tools installed on all VMs? You will need to prepare for duplicate hostnames (e.g. when you clone a VM and the clone retains the old hostname, etc.) Mircea Vutcovici Jun 24 at 21:39

You cannot do this with VMware Tools alone from inside the VM. You need to connect to and query vCenter, e.g. with PowerCLI. And that you can do from any machine on the network. The following PowerCLI code should do the trick:

Connect-VIServer vcenter-address
foreach ($vm in (get-vm)) { $vm.Name + ": " + $vm.ExtensionData.Guest.Hostname }

That shows the vCenter display name and the internal host name (as reported by VMware Tools) for each VM. So this requires VMware Tools running in the VMs.

PowerCLI is also available for Powershell Core, so you can also run this on Linux if you do not have any Windows machines available.

You can install PowerCLI and then use the Get-VMGuest command.

Have a look at this also, to get a list of all VMs, name, hostname, IP: get list of VMs

Thanks for contributing an answer to Server Fault!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.