Using PowerCLI to Install Host VIBs
So currently Cisco has an issue with installing their ENIC and FNIC VIBs through Update Manager for ESXi 6.x. Until that is resolved I need to manually push out patches to these hosts. Obviously I do not want to do this manually, so I will be utilizing PowerCLI to accomplish this task.
Pre-Requsites
Link to Script
Preparing to Execute the Script
The script is pretty straight forward, just need to define a few variables seen below and then you execute the script. I will walk you through the process.
This script assumes you have already launched PowerCLI and modified the variables
1# Define Variables
2$Cluster = "Cluster"
3$VIBPATH = "/vmfs/volumes/NFS01/VIB/cisco/scsi-fnic_1.6.0.24-1OEM.600.0.0.2494585.vib"
4$vcenter = "vcenter.lab.local"
5$cred = Get-Credential
6
7# Connect to vCenter
8Connect-VIServer -Server $vcenter -Credential $cred
9
10# Get each host in specified cluster that meets criteria
11Get-VMhost -Location $Cluster | where { $_.PowerState -eq "PoweredOn" -and $_.ConnectionState -eq "Connected" } | foreach {
12
13 Write-host "Preparing $($_.Name) for ESXCLI" -ForegroundColor Yellow
14
15 $ESXCLI = Get-EsxCli -VMHost $_
16
17 # Install VIBs
18 Write-host "Installing VIB on $($_.Name)" -ForegroundColor Yellow
19 $action = $ESXCLI.software.vib.install($null,$null,$null,$null,$null,$true,$null,$null,$VIBPATH)
20
21 # Verify VIB installed successfully
22 if ($action.Message -eq "Operation finished successfully."){Write-host "Action Completed successfully on $($_.Name)" -ForegroundColor Green} else {Write-host $action.Message -ForegroundColor Red}
23}
Execute the Script
- Run .\Install-HostVIB.ps1