Search for host ID from vCenter.
search cancel

Search for host ID from vCenter.

book

Article ID: 423874

calendar_today

Updated On:

Products

VMware vCenter Server VMware vSphere ESXi

Issue/Introduction

This article introduces how to search for host ID from vCenter by querying the vCenter vPostgres Database (VCDB).

Resolution

  1. SSH to vCenter with root account.
  2. Execute the following command to connect to the VCDB and query for all hosts. The ESXi host ID would be listed in the first column of the output:

     

    /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres -c "select id,name from vpx_entity where type_id=1;"

     

  3. To disconnect from vPostgres, enter the following command:

    \q

Example Output:

root@vCenter [ / ]# /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres -c "select id,name from vpx_entity where type_id=1;"

  id   |     name
-------+--------------
00001 | ESXi-1.com
00002 | ESXi-2.com
00003 | ESXi-3.com
(3 rows)