«

»

Aug 13

Automate the Install of Embedded Host Client for ESXi fling on all hosts in a cluster

Install-HostClient

It’s true! If you are reading this then you already know that there is a new VMware fling that rocks this world! You can read more about it on William Lam’s blog HERE:

Now, to be able to use the Embedded Host Client for ESXi fling, you will need to:

  • download the VIB from the VMware Flings site HERE:
  • WinSCP the VIB to each esx host (or place on a datastore)
  • Enable SSH on each host
  • Putty/SSH each host and run the vib-install command
  • Disable SSH

ok, for the functionality gained by this fling, it’s worth it to do those steps above. But what if you could do it all with PowerCLI in one command?

I’ve created two advanced functions that I think you will like. The first is Install-HostClient, which will copy the VIB to shared storage and automatically install the VIB on all hosts in the specified cluster, all in a single command. you ready??

Install-HostClient

you can copy and paste the code below, or you can also find this script on my Github repo HERE.

Install-HostClient requires three parameters to be set (as well as be connected to vCenter):

  • Datastore (must be shared storage)
  • Cluster (the cluster where you will install the vib)
  • vibfullpath (the full path to the vib on your local machine)

The command would look like this:

 

or you could also pre-define the datastore and cluster with variables and then place the variables in the command:

 

You will notice that the script requires the datastore and cluster objects, not just a string/name for each. Once the command is executed it will upload the vib to the parent directory of the designated datastore, then loop through each host.

The script checks to see if the vib is already installed or not. If it is, the script will skip that host, otherwise it will install.

It will also verify that the vib installed correctly, if it does not, it will give you an error message and move on.

As you can see in the screenshot:

Install-HostClient

Remove-HostClient

Similar to the ability of the Install-HostClient function. This will allow you to bulk-remove the vib if necessary.

This function only requires a single parameter, which is -Cluster. the command would look like this:

Remove-HostClient

You can find this on github HERE.

or Copy and paste from below:

 

As always, read through the script and understand exactly what is going on before running it. This is not supported (nor is the fling).

 

Cheers!

2 comments

  1. ShoGuevara

    You can use this piece of code to deliver VIB file automatically – you only need to have a list of hosts (this one was for hp servers)

    $Hosts=
    $Us=”root”
    $Pass=”password for root”
    $filename = “C:localfolderlocalfile_1″
    $dest=”/tmp/localfile_1″
    $vibname=”vibname”
    $sc_dir=”C:localfolder”

    foreach ($item in $Hosts) {
    $HName=$item.name
    write-host $HName

    if ($HName -like “mask*”) { ###you can use some masks here
    cd $sc_dir
    ###you don’t need the string below in case you already connected to the host using the same SSH client and already has it’s keys as trusted
    echo Y | .pscp.exe $filename $Us@”$HName”:$dest
    echo $Pass | .pscp.exe $filename $Us@”$HName”:$dest
    }

    cd “C:Program Files (x86)VMwareVMware vSphere CLIbin”
    ./esxcli –server=$HName -u $Us -p $Pass software vib remove –vibname=$vibname
    }

  2. ShoGuevara

    Please, remove last 3 strings from my comment =)
    Or it could be removed totally 😉

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

sixteen − two =