Using VMware vCLI

I recently had to start using VMware’s vCLI to perform tasks that I used to do directly on the ESXi host. In this case, I needed to remove a VIB that I no longer needed. This is assuming that you have a vCenter server managing your ESXi hosts. If you do not, skip the vihost command.

Authentication

First, you need to perform a onetime authentication so you are always authenticated via SSH keys.
Run the following command:

esxcli --server=vcenterhostname --vihost=esxhostname --username vcenterusername --password MyPassword software vib list

You should receive an error looking something like untrusted certificate, and the SSH thumbprint. Copy this SSH thumbprint, as we need it later.

vCLI uses the Perl credential store to handle authentication, so you’ll need to do the following:

cd Perl/apps/general
credstore_admin.pl add --server vcenterhostname --username vcenterusername --password MyPassword
credstore_admin.pl add --server vcenterhostname --thumbprint [SSH Thumbprint that we copied earlier]

At this point, we are now authenticated via SSH keys with our vCenter host, so we no longer need to use usernames or passwords in any of our vCLI commands.

Remove a VIB

To uninstall a VIB, first you need to put the ESXi host in maintenance mode

vicfg-hostops.pl --server=vcenterhostname --vihost=esxhostname --operation enter

Next you’ll want to list out the installed VIB’s to see which VIB you want to uninstall

esxcli --server=vcenterhostname --vihost=esxhostname software vib list

Lastly, copy the VIB name that you want to uninstall, and run

esxcli --server=vcenterhostname --vihost=esxhostname software vib remove --vibname=[vib name]

This entry was posted in VMWare and tagged , , , , . Bookmark the permalink.

Comments are closed.