2014/11/26

Finding VIBs on ESXi hosts with PowerCLI

I did not work with PowerCli for the last couple of months and I had an interesting question from one of my follower Ivo from Netherlands.

He was trying to retrieve the VIB information with the name 'net-e1000e' from all his VMware Hosts using the PowerShell and the Snapin PowerCli from VMware.


What is a VIB ?
VIB stands for vSphere Installation Bundle.  At a conceptual level a VIB is somewhat similar to a tarball or ZIP archive in that it is a collection of files packaged into a single archive to facilitate distribution


Here is the piece of code to retrieve this information.
The output is sent to Out-GridView which create a simple GUI.

Get-VMHost | Where-Object { $_.ConnectionState -eqConnected” } | Foreach-Object {
    $CurrentVMhost = $_
    TRY
    {
        # Exposes the ESX CLI functionality of the current host
        $ESXCLI = Get-EsxCli -VMHost $CurrentVMhost.name
        # Retrieve Vib with name 'net-e1000e'
        $ESXCLI.software.vib.list() | Where-Object { $_.Name -eq "net-e1000e" } |
        FOREACH
        {
            $VIB = $_
            $Prop = [ordered]@{
                'VMhost' = $CurrentVMhost.Name
                'ID' = $VIB.ID
                'Name' = $VIB.Name
                'Vendor' = $VIB.Vendor
                'Version' = $VIB.Version
                'Status' = $VIB.Status
                'ReleaseDate' = $VIB.ReleaseDate
                'InstallDate' = $VIB.InstallDate
                'AcceptanceLevel' = $VIB.AcceptanceLevel
            }#$Prop
            
            # Output Current Object
            New-Object PSobject -Property $Prop
        }#FOREACH
    }#TRY
    CATCH
    {
        Write-Warning -Message "Something wrong happened with $($CurrentVMhost.name)"
        Write-Warning -Message $Error[0].Exception.Message
    }
} | Out-GridView


Script Version


I also wrote a more complete version available on Github


Thanks for reading! If you have any questions, leave a comment or send me an email at [email protected] I invite you to follow me on Twitter @lazywinadm / Google+ / LinkedIn. You can also follow the LazyWinAdmin Blog on Facebook Page and Google+ Page.

2 comments:

  1. The Microsoft.EnterpriseManagement.Core Version 7.0.5000.0 is already available in the c:\windows\assembly. But whenever I run the import-module SMLets I get the following error.

    import-module : Could not load file or assembly 'Microsoft.EnterpriseManagement.Core, Version=7.0.5000.0, Culture

    PublicKeyToken=9396306c2be7fcc4' or one of its dependencies. The system cannot find the file specified.
    At line:1 char:1
    + import-module smlets
    + ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand





    I also did the specified changes to SMLets.psm1 file. But still no luck. Please help me out.

    ReplyDelete
  2. Hey Malik,



    Make sure you unblock smlets files after you downloaded it and unpack the zip.
    You also need SCSM console install on the machine that will run the scripts (this will install some NET Library required by smlets)

    ReplyDelete