Problem

When transitioning environments from vSphere Baselines to vSphere Lifecycle Manager (vLCM), certain legacy components may need to be removed from hosts.

One common example is the VMware Tools VIB (tools-light). In environments where VMware Tools are managed differently, or when preparing clusters for image-based lifecycle management, this VIB must be removed.

In small environments this might not be a big deal. But in larger clusters the reality quickly becomes painful:

  • Dozens of ESXi hosts need modification

  • Each host must be checked individually

  • The VIB must be verified before removal

  • The process often involves SSH access to every host

Manually repeating this process across multiple hosts is tedious, time consuming, and prone to human error.

There had to be a better way.


Troubleshooting

The first approach most administrators take is the traditional route:

  1. SSH into each ESXi host

  2. Run esxcli software vib list

  3. Verify whether the VIB is installed

  4. Execute esxcli software vib remove -n tools-light

While this works, it introduces several problems:

  • Time consumption: Performing this operation across large clusters can take hours

  • Operational overhead: Enabling and managing SSH access on hosts is often undesirable

  • Human error: Running commands manually increases the risk of mistakes

  • Inconsistent results: Hosts may be skipped or handled differently

Since PowerCLI already provides access to ESXi host functionality through the ESXCLI interface, automation becomes the logical solution.


Solution

To simplify the process I created a PowerShell script called:

Bulk-Remover-Vibs (BRV)

The script removes a specific VIB from all hosts in a cluster, without requiring SSH access to individual hosts.

Instead it:

  • Connects directly to vCenter

  • Enumerates all hosts in the specified cluster

  • Checks whether the target VIB exists

  • Removes it if present

  • Reports the result per host

This allows administrators to perform the operation across an entire cluster in seconds.


Script Functionality

The BRV script automates the following workflow:

  1. Connects to the specified vCenter Server

  2. Retrieves the cluster object

  3. Enumerates all connected ESXi hosts

  4. Uses Get-EsxCli (V2) to interact with the host software stack

  5. Checks whether the target VIB exists on each host

  6. Removes the VIB if it is present

  7. Provides clear output showing success or status messages

  8. Handles errors through try/catch blocks

  9. Gracefully disconnects from vCenter after execution

Key design considerations included:

  • Avoiding SSH access

  • Ensuring safe execution

  • Providing clear feedback during execution

  • Allowing repeated runs without causing issues

 

.Bulk-Remover-Vibs.ps1 -vCenter "vcenter.local.domain" -ClusterName "test-cl01" -TargetVib "tools-light"

Example output:

VIB 'tools-light' gevonden op esx01.local. Verwijderen gestart...
[SUCCESS] esx01.local: Operation finished successfully.

VIB 'tools-light' gevonden op esx02.local. Verwijderen gestart...
[SUCCESS] esx02.local: Operation finished successfully.

Host esx03.local: VIB niet gevonden.

 

Real-World Implementation

Scenario: Migrating a cluster from Baselines to vLCM image-based lifecycle management.

Before using this script:

  • Hosts required manual SSH access

  • Commands had to be executed individually

  • The process took 30–60 minutes per cluster

After implementing the script:

  • Entire cluster processed automatically

  • No SSH required

  • Execution time reduced to seconds

This significantly simplifies preparing clusters for vLCM image compliance.


Benefits

Using this script provides several advantages:

  • Time savings: Remove VIBs across clusters within seconds

  • Consistency: Ensures all hosts are processed the same way

  • Security: No need to enable SSH on hosts

  • Automation ready: Easily integrated into operational workflows

  • Safe execution: Only removes the VIB when it actually exists

  • Clear logging: Immediate feedback per host


Complete Script

 <#
.SYNOPSIS
Script: Bulk-Remover-Vibs (BRV)
Version: 1.0
Date: March 12, 2026
Author: Kabir Ali - [email protected]
Description: This script removes VIBs from all hosts in a cluster without the need to SSH into every single host

Version history:
0.1 - March 12, 2026 - Initial version
1.0 - March 12, 2026 - Validated by customer

.EXAMPLE
.Bulk-Remover-Vibs.ps1 -vCenter "vcenter.local.domain" -ClusterName "test-cl01" -TargetVib "tools-light"
#>

[CmdletBinding()]
param (
    [Parameter(Mandatory = $true, HelpMessage = "De FQDN van de vCenter server.")]
    [string]$vCenter,

    [Parameter(Mandatory = $true, HelpMessage = "Naam van het cluster waar de hosts in staan.")]
    [string]$ClusterName,

    [Parameter(Mandatory = $false)]
    [string]$TargetVib = "tools-light",

    [Parameter(Mandatory = $false)]
    [switch]$Force # Optioneel: voor als je later destructievere acties wilt forceren
)

process {
    try {
        # 1. Connectiviteit checken
        if ($global:DefaultVIServer.Name -notcontains $vCenter) {
            Write-Verbose "Verbinding maken met $vCenter..."
            Connect-VIServer -Server $vCenter -ErrorAction Stop
        }

        # 2. Cluster object ophalen
        $cluster = Get-Cluster -Name $ClusterName -ErrorAction Stop
        $esxHosts = $cluster | Get-VMHost | Where-Object { $_.ConnectionState -eq "Connected" }

        if (-not $esxHosts) {
            Write-Warning "Geen actieve hosts gevonden in cluster $ClusterName."
            return
        }

        # 3. Iteratie over de hosts
        foreach ($esx in $esxHosts) {
            $esxcli = Get-EsxCli -VMHost $esx -V2
            
            # Gebruik de .Where() methode voor snelheid
            $vib = $esxcli.software.vib.list.Invoke().Where({$_.Name -eq $TargetVib})

            if ($vib) {
                $statusMsg = "VIB '$TargetVib' gevonden op $($esx.Name). Verwijderen gestart..."
                Write-Host $statusMsg -ForegroundColor Cyan
                
                $result = $esxcli.software.vib.remove.Invoke(@{vibname = $vib.Name})
                Write-Host "[SUCCESS] $($esx.Name): $($result.Message)" -ForegroundColor Green
            } else {
                Write-Verbose "Host $($esx.Name): VIB niet gevonden."
            }
        }
    }
    catch {
        Write-Error "Kritieke fout: $($_.Exception.Message)"
    }
    finally {
        # Netjes afsluiten
        if ($global:DefaultVIServer) {
            Disconnect-VIServer -Server * -Confirm:$false -ErrorAction SilentlyContinue
        }
    }
}

 

The original article was posted on: whatkabirwrites.nl

Related articles

  • Hybrid Cloud
  • Cloud Native
  • Dev Enablement
  • Platform Engineering
  • Implementation and Adoption
  • Digital Workspace
  • Application Management Services
  • Data Center Modernization
  • Managed Cloud Platform
  • Public Cloud Landing Zones
  • Sovereign Cloud
Visit our knowledge hub
Visit our knowledge hub
Kabir Ali IT Consultant

Let's talk!

Knowledge is key for our existence. This knowledge we use for disruptive innovation and changing organizations. Are you ready for change?

"*" indicates required fields

First name*
Last name*
This field is hidden when viewing the form