VMware

Finding ESXi version via script

I have a problem that I’ve been bashing my head against for far too long.

I need to get the version information for ESXi running on several clusters. Sounds really simple, but I’m running into limitations based on my environments.

Details:

– Working with PowerShell 5.1, I should have access to SSH
– Script needs to be compatible with multiple dark sites so installing new things (eg powercli, python is not preferred). If installing something new, SSH is preferred since it’s multi purpose
– Trying to enter as few passwords as possible to minimise input requirements
– OpenSSH does not come with ssh-copy-id to set up SSH keys

Attempts so far:

1. PowerCli: get-vmhost gives me exactly what I need but isn’t available in most cases
2. VMware REST API: I can access vcenter version information from here, and can get a list of the hosts, but not software versions on the hosts
3. OpenSSH: works fine if nutanix is installed as this gives access to a Linux VM with host keys installed, so I can do passwordless SSH for the hosts after initial connection (1 password entry only)
4. SSH directly to host: requires up to 7 password entries. I’m okay with prompting once and reusing the password, but OpenSSH uses terminal entry for the password and I can’t figure out how to fill this (and yes I know keys are the proper way to do this :)). Python is on the hosts (just not the machine the script runs from) so I could connect to one and jump out from there, but paramiko is not and I can’t get python to grab the terminal input.
5. Esxcfg-info.cgi url: I can get 200000 lines of plain text with every bit of information I could possibly need, but surely there’s an easier way?

Appreciate any advice (preferably someone telling me I’m missing something super obvious and there’s an easy way to do this). With no other options I’ll probably go down the SSH password prompt route and push for better set up moving forward ?

Thanks!


View Reddit by owliness333View Source

Related Articles

3 Comments

  1. Best (and easier) way (at least for me) is PowerCLI, why you say “isn’t available in most cases”? Did you get any error?

  2. If you have access to vCenter you can query VCDB for this info:

    `/opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres -c “SELECT dns_name,ip_address,product_fullname FROM vpx_host”`

    Edit: access to the vCenter appliance console, that is

Leave a Reply

Close