Skip to content
vJAL.nl
  • Partners
    • Vembu
  • About me
  • Home
  • Search Icon
Uninstalling a VIB leveraging PowerCLI

Uninstalling a VIB leveraging PowerCLI

13 August 2020 Jesper Alberts Comments 2 comments

“My problem”

A lot of my customers running VMware Horizon have been using NVIDIA GPU’s in their ESXi hosts leveraging vGPU to accelerate their virtual desktops, especially since they made the move to Windows 10. When using vGPU one of the requirements is the installation of a driver on the ESXi host(s) which has the NVIDIA card installed.

But when you add a component this also means you’ll have to maintain it, meaning from time to time it will require updating. Especially since NVIDIA introduced two separate release branches:

  • Long-Term support branch – which has support for three years after the initial release
  • New-Feature branch –  which has support for one year after the initial release

Seeing as both VMware and Microsoft frequently release new versions of their products it’s import to keep the entire chain in a supported state, which can be a puzzle sometimes.
Luckily VMware has a KB article which describes the process of updating the driver. In short it comes down to:

  • Make sure there are no VM’s running on the host using the graphics card
  • Place the host in maintenance mode
  • Uninstall the VIB
  • Install the new VIB

Especially the part where you uninstall and install the VIB can be time consuming job, as you normally do this through a command prompt on the ESXi host. So when you have to do this on several ESXi hosts you can image the amount of time and effort it takes to complete this task.

“My solution”

To make it less of a hassle I’ve written a PowerCLI script which removes a specified VIB of all ESXi hosts which are in maintenance mode.

In short the script saves all ESXi hosts in maintenance mode in a variable, and loops the removal of the specified VIB (in this case the NVIDIA one). Expect an updated version soon, as I’m working on a version which includes automatically rebooting the ESXi hosts (when required) and installing the new VIB afterwards.

You can download or copy the code in it’s current state below.

Uninstall_VIB_from_multiple_hosts-1Download
 <#
.SYNOPSIS
    Uninstall_VIB_from_multiple_hosts.ps1 - PowerShell Script to remove VIBs from one or more ESXi hosts.
.DESCRIPTION
    This script is used to delete a VIB from one or more ESXi hosts (depending on how you change line 15).
    By default the script will run against all ESXi hosts which are placed in maintenance mode.
    At this moment rebooting a host is a manual action, the requirement of a reboot will be printed to the console
.OUTPUTS
    Results are printed to the console.
.NOTES
    Author        Jesper Alberts, Twitter: @jesperalberts, Blog: www.vjal.nl

    Change Log    V1.00, 22/07/2019 - Initial version
#>

$vCenterServer = Read-Host "Enter the vCenter Server hostname"
$AdminUsername = Read-Host ("Enter the username for the administrative account")
$AdminPassword = Read-Host ("Password for " + $AdminUsername) -AsSecureString:$true
$Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $AdminUsername, $AdminPassword

Connect-VIServer -Server $vCenterServer -Credential $Credentials

$ESXiHosts = Get-VMHost | Where { $_.ConnectionState -eq "Maintenance" }
$VIBs = @("NVIDIA-VMware_ESXi_6.7_Host_Driver")

Foreach ($ESXiHost in $ESXiHosts) {
    Write-host "Working on $ESXiHost."
    $ESXCLI = get-esxcli -vmhost $ESXiHost
    foreach ($VIB in ($VIBs)) {
        write-host "Searching for VIB $VIB." -ForegroundColor Cyan
        if ($ESXCLI.software.vib.get.invoke() | where { $_.name -eq "$VIB" } -erroraction silentlycontinue ) {
            write-host "Found vib $VIB on $ESXiHost, deleting." -ForegroundColor Green
            $ESXCLI.software.vib.remove.invoke($null, $true, $false, $true, "$VIB")
        }
        else {
            write-host "VIB $VIB not found on $ESXiHost." -ForegroundColor Yellow
        }
    }
}
Please follow and like us:
Tweet

PowerCLI
NVIDIA, PowerCLI, VMware vSphere

Post navigation

PREVIOUS
My VMware VCAP6-DTM Deploy (3V0-653) experience
NEXT
Using the new Elevated Task feature in DEM to manage registry keys in HKLM

2 thoughts on “Uninstalling a VIB leveraging PowerCLI”

  1. Evan says:
    26 March 2021 at 04:28

    This is the same as all of the other scripts that I have found. What I REALLY need is a script that will invoke the remove command, and then move on to the next host, without waiting for the VIB to be removed first. I have over 800 hosts that I need to remove 2 VIBs from, and if I have to wait for each of the two VIBs to be removed from each of the hosts before the script can continue to the next VIB/host, it’s going to take 3 days for this script to complete. Is there no way to kick off the VIB removal process, and then move on to the next host immediately? I know I can’t remove more than 1 VIB from a host at a time, so I would still need to run the script twice… Once for the first VIB, and a second time for the second VIB, but if it could just kick the removal command off, and then move on, it would only take me about an hour to remove these VIBs, rather than a few days.

    Reply
    1. Jesper Alberts says:
      26 March 2021 at 09:30

      You’re absolutely right that this will take a long time. Back when I wrote this script the Parallel feature wasn’t available yet and unfortunately you cannot use -RunAsync.

      I’ll try and see if I can create a new version of the script during the next couple of days using ForEach -parallel, and compare it to the current version.

      Reply

Leave a Reply Cancel reply

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

Let’s stay in touch!

Twitter
LinkedIn

Blog sponsors

Recent Posts

  • Vembu BDRSuite Backup for Microsoft 365 v5.1 hands-on experience [sponsored]
  • Deploying and configuring the NVIDIA DLS licensing appliance
  • Quick tip: Controlling SEGv2 cipher suites and scoring an A+ at SSL Labs
jesperalbertsJesper Alberts@jesperalberts·
23 May

It looks like @AgeRoskam, and I will be presenting at the @vmugnl about the @WorkspaceONE suite and how modern management can positively impact your daily operations while still providing a kick-ass employee experience! #vExpertEUC #ITQlife

The Dutch VMUG@vmugnl

De eerste #VMUGNL sessies zijn geaccepteerd en de sprekers zijn al geïnformeerd.

Gefeliciteerd en tot 14 juni in Utrecht.

Houd onze social media in de gaten, binnenkort delen we de agenda.

En schrijf je in op: http://vmugticketsemea.nl

Reply on Twitter 1528698463722123267Retweet on Twitter 15286984637221232675Like on Twitter 152869846372212326724Twitter 1528698463722123267
Retweet on TwitterJesper Alberts Retweeted
impauldirmannPaul Dirmann@impauldirmann·
22 May

If you're attempting your #vcdx, from one candidate to another I highly recommend joining the #slack channel and forming up a study group with others! In my case, it has proven to be helpful 10x over!

#vexpert #vcdx #vmware #dirmanntech

Reply on Twitter 1528403586958475265Retweet on Twitter 15284035869584752657Like on Twitter 152840358695847526510Twitter 1528403586958475265
jesperalbertsJesper Alberts@jesperalberts·
20 May

And that's a wrap for the first week of #CALAAC. Wow! This course exceeds all my expectations in any possible way. I'm tired but satisfied. Time to charge the battery and do some homework! #ITQlife

Reply on Twitter 1527645079887912960Retweet on Twitter 15276450798879129601Like on Twitter 152764507988791296013Twitter 1527645079887912960
jesperalbertsJesper Alberts@jesperalberts·
18 May

Hi @aprAmac! De Logitech Spotlight Presenter (910-004861) is momenteel nergens op voorraad bij jullie, maar lijkt wel te bestellen. Komt deze binnenkort weer op voorraad?

Reply on Twitter 1526862652785541120Retweet on Twitter 1526862652785541120Like on Twitter 1526862652785541120Twitter 1526862652785541120
jesperalbertsJesper Alberts@jesperalberts·
16 May

Day 1 of #CALAAC is here! #vExpert #ITQlife

Reply on Twitter 1526099039795785729Retweet on Twitter 15260990397957857291Like on Twitter 152609903979578572913Twitter 1526099039795785729
Load More...

Archives

  • March 2022
  • August 2021
  • January 2021
  • October 2020
  • August 2020

Categories

  • BCDR
  • Certification
  • Dynamic Environment Manager
  • Horizon
  • NVIDIA vGPU
  • Partners
  • Personal
  • PowerCLI
  • Secure Email Gateway
  • UAG
  • Uncategorized

Tags

Back-up BCDR Certificates Certification DEM Dynamic Environment Manager Horizon Identity Manager ITQ Job Licensing Microsoft 365 NVIDIA Personal PowerCLI Replication SEG SEGv2 SSL SSLLABS Troubleshooting True SSO UAG Upgrading VCAP VCIX Vembu vGPU VMware Tools VMware vSphere Workspace One Access
© 2022   All Rights Reserved.