Skip to content

Instantly share code, notes, and snippets.

@alanrenouf
Last active February 24, 2021 07:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanrenouf/b515bb6ff1259f0d594b to your computer and use it in GitHub Desktop.
Save alanrenouf/b515bb6ff1259f0d594b to your computer and use it in GitHub Desktop.
Download and Install ESXi Host Client on all hosts in vCenter
Connect-viserver 10.160.200.218 -user administrator@vsphere.local -Password "Admin!23"
Write-Host "Downloading latest Host Client VIB" -ForegroundColor Green
$source = "http://download3.vmware.com/software/vmw-tools/esxui/esxui_signed.vib"
$Vib = "$ENV:Temp" + "\esxui_signed.vib"
Invoke-WebRequest $source -OutFile $Vib
$Vibname = $vib.split("\")[-1]
Get-VMHost | Foreach {
Write-host "Installing ESXUI on $($_)" -ForegroundColor Green
$datastore = $_ | Get-Datastore | Where {-Not $_.ExtensionData.Summary.MultipleHostAccess -and $_.Extensiondata.Info.vmfs} | Sort FreespaceGB -Descending | Select -first 1
If (-not $Datastore) {
Write-Host "Local Datastore not found trying any with space" -ForegroundColor Green
$datastore = $_ | Get-Datastore | Sort FreespaceGB -Descending | Select -first 1
}
$remoteLocation = "/vmfs/volumes/" + $datastore + "/" + $Vibname
$Psdrive = New-PSDrive -name "VIBDS" -Root \ -PSProvider VimDatastore -Datastore $datastore
Write-Host "..Copying file to $datastore" -ForegroundColor Green
$CopyVIB = Copy-Datastoreitem $VIB -Destination VIBDS:
Write-host "..Installing VIB on $($_)" -ForegroundColor Green
$esxcli = Get-EsxCli -VMHost $_
$esxcli.software.vib.install($null,$false,$true,$false,$false,$true,$null,$null,$remotelocation)
Write-Host "Host Client Installed, removing install file from $datastore" -ForegroundColor Green
Get-childitem "$($psdrive.Name):\esxui_signed.vib" | Remove-Item
Remove-PSDrive -name VIBDS -Confirm:$false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment