Installing Host VIB's Using PowerCLI
Normally when i need to install and update a host VIB I use Update Manager. However there is currently a bug with Cisco’s latest enic/fnic drivers that wont let you install them via UM.
I had to run these updates on over 50 hosts and I really didn’t want to have to ssh and install it manually. Lucky I remember Brian Graf’s Host Client Install Fling and borrowed some of the code to come up with the below script.
All you need to do is input your cluster and specify what VIB’s you want to install. You can see the VIBPath and the Actions and just add or delete them as needed for the VIB’s you want to install.
1# Define Variables
2$Cluster = "Cluster"
3$VIBPATH1 = "/vmfs/volumes/NFS01/VIB/cisco/net-enic-2.1.2.71-1OEM.550.0.0.1331820.x86_64.vib"
4$VIBPATH2 = "/vmfs/volumes/NFS01/VIB/cisco/scsi-fnic-1.6.0.17a-1OEM.550.0.0.1331820.x86_64.vib"
5
6
7# Get each host in specified cluster that meets criteria
8Get-VMhost -Location $Cluster | where { $_.PowerState -eq "PoweredOn" -and $_.ConnectionState -eq "Connected" } | foreach {
9
10 Write-host "Preparing $($_.Name) for ESXCLI" -ForegroundColor Yellow
11
12 $ESXCLI = Get-EsxCli -VMHost $_
13
14 # Install VIBs
15 Write-host "Installing VIB on $($_.Name)" -ForegroundColor Yellow
16 $action = $ESXCLI.software.vib.install($null,$null,$null,$null,$null,$true,$null,$null,$VIBPATH1)
17 $action2 = $ESXCLI.software.vib.install($null,$null,$null,$null,$null,$true,$null,$null,$VIBPATH2)
18
19 # Verify VIB installed successfully
20 if ($action.Message -eq "Operation finished successfully."){Write-host "Action Completed successfully on $($_.Name)" -ForegroundColor Green} else {Write-host $action.Message -ForegroundColor Red}
21 if ($action2.Message -eq "Operation finished successfully."){Write-host "Action Completed successfully on $($_.Name)" -ForegroundColor Green} else {Write-host $action.Message -ForegroundColor Red}
22}
Hope this helps anyone else out wanting to automate vib installation using PowerCLI.
comments powered by Disqus