WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Automation / Using the vSphere API to remotely collect ESXi esxcfg-info

Using the vSphere API to remotely collect ESXi esxcfg-info

06.15.2016 by William Lam // 7 Comments

Using the same technique as I have described here, you can now also use the vSphere API to connect to vCenter Server to remotely collect esxcfg-info from ESXi hosts without having to SSH'ing to each and every single host. Historically, the esxcfg-* commands were only available in the classic ESX Service Console (COS) and the ESXi Shell. As part of the ESXi transition, VMware has converted all the commands over to the vSphere API which means that you no longer needed to run those local CLIs commands to manage or configure your ESXi hosts like you used to with classic ESX.

The only exception that still exists today is the esxcfg-info command, which still contains a lot of useful information, for some of which is not currently in the vSphere API today. Similiar to the vm-support.cgi script, there is also an esxcfg-info.cgi script which I had blogged about here back in 2011. To output the esxcfg-info, simply open a web browser and specify the following URL with the Hostname/IP Address of your ESXi host:

https://esxi-1.primp-industries.com/cgi-bin/esxcfg-info.cgi

Once you have authenticated with a valid user, you will see that the output matches the output if you were to manually run esxcfg-info command on the ESXi Shell.

esxcfg-info-regular-output
Instead of the raw output that you are all probably familiar with, you can also format the output using XML simply by appending ?xml to the end of the URL:

https://esxi-1.primp-industries.com/cgi-bin/esxcfg-info.cgi?xml

esxcfg-info-xml-output
With the second formatted option, we can now easily retrieve the result and store that into an XML object for processing using any one of our favorite scripting/programming languages. In the previous article, I demonstrated the use of the vSphere API method AcquireGenericServiceTicket() using a pyvmomi (vSphere SDK for Python) script. In this example, I will demonstrate the exact same use of the vSphere API but now leveraging PowerCLI. I have created a script called Get-Esxcfginfo.ps1 which connects to a vCenter Server and requests a session ticket to a specific ESXi host's esxcfg-info.cgi URL and that will then return us a one time HTTP request to connect to the ESXi host to retrieve the requested information.

Here is an example on how to use the command which will return the XML output which would then require further processing of the XML:

$xmlResult = Get-VMHost -Name "192.168.1.190" | Get-Esxcfginfo

I have also included an example of how to parse the XML return in the script itself. As you can see from the screenshot below, I am extracting the Device Name, Vendor Name & Vendor ID from the esxcfg-info output.

vsphere-api-to-access-esxcfg-info

Pretty cool huh? Stay tuned for one more blog post which I will show you another way in which you can make use of this vSphere API!

More from my site

  • How do you "log a reason" using PowerCLI when rebooting or shutting down ESXi host?
  • Identifying ESXi boot method & boot device
  • PowerCLI script to help correlate vCenter, ESXi & vSAN build/versions w/o manual VMware KB lookup
  • Quick Tip - How to retrieve the ESXi Update Level using the vSphere API?
  • Using the vSphere API to remotely collect ESXi configuration file (esx.conf)

Categories // Automation, ESXi, PowerCLI, vSphere Tags // esxcfg-info, ESXi, PowerCLI, vCenter Server, vSphere API

Comments

  1. *protectedSchorschi says

    06/20/2016 at 9:23 am

    Why not make Get-esxcfginfo.ps1 more generic? Show how to pass in parameters? or does the cgi implementation not allow that feature?

    Reply
    • William Lam says

      06/20/2016 at 9:38 am

      The underlying CGI implementation only supports 1 option 🙂

      Reply
  2. *protectedAaron Longchamps (@Aaron416) says

    06/23/2016 at 7:14 pm

    Do you know if this is adaptable to having a REST call from VMware Orchestrator? I'm asking since there are certain properties not available at all in the vSphere API, but PowerCLI and https://hostName/host/esx.conf do have those properties available.

    Reply
    • William Lam says

      06/23/2016 at 7:19 pm

      Aaron,

      Yes, given these are just HTTP URLs, you can definitely use vCO or any other solution to perform an HTTP GET

      Regarding esx.conf, see my latest blog post 🙂 http://www.virtuallyghetto.com/2016/06/using-the-vsphere-api-to-remotely-collect-esxi-configuration-file-esx-conf.html

      Reply
      • *protectedAaron Longchamps (@Aaron416) says

        06/24/2016 at 5:17 am

        I did see that post, but had issues setting the cookies. I can do everything else with code (add REST host, REST operation, get auth token) but didn't find a way to set cookies in vRO 6 REST. Do you have any pointers on that? Thanks!

        Reply
  3. *protectedJayaraghavendra says

    11/29/2017 at 6:47 am

    Hi

    I was looking to get the details of storageHeap and below 10 lines like below;
    |----Name............................................storageHeap
    |----Growable........................................true
    |----Max Size........................................62763864 bytes
    |----Max Available...................................57474368 bytes
    |----Current Size....................................11539288 bytes
    |----Current Allocation..............................5289496 bytes
    |----Current Available...............................6249792 bytes
    |----Current Releasable..............................0 bytes
    |----Percent Free of Current.........................54
    |----Percent Free of Max.............................91
    |----Percent Releasable..............................0

    is this possible to get ?? If yes any chance how from your script?

    Thanks in advance.

    Reply
  4. *protectedDeepali says

    05/25/2022 at 7:58 am

    Hi William,
    great work making the large output of esxcfg-info available remotely through browser.
    I want to know if there is any cli command or an API that will give me the a more elaborate list of smart parameter values of physical disks on the host.

    Would appreciate your response.
    Thank you
    Dee

    Reply

Thanks for the comment!Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025

 

Loading Comments...