• Skip to primary navigation
  • Skip to main content

jdgreen.io

The personal blog of James Green

  • Home
  • Technology
    • Announcements
    • Industry
    • Reviews/Guides
    • Tech Field Day
    • Interviews
  • Health
    • Food
    • Biohacking
    • Fitness
  • Faith
  • Book Notes
    • Business Books
    • Faith Books
    • Health Books
    • Technology Books
  • About
  • Show Search
Hide Search

Check VIB installation with PowerCLI

James Green · Feb 14, 2014 ·

This is super ugly, but I wanted as few lines as possible. Given a certain VIB name, this should give you a table of which hosts it is and isn’t loaded on. $True would indicate that it is installed. Maybe @alanrenouf can show me the PROPER way to do this 🙂

[code language=”powershell”] $VIBinstalled = @{}

Get-VMHost | Sort Name | %{
$VIBinstalled.Add($_,((Get-EsxCli -VMHost $_).software.vib.list() |
Where-Object {$_.Name -like ""}) -ne $null)}

$VIBinstalled
[/code]

Here’s a screenshot:

Screen Shot 2014-02-14 at 3.43.30 PM

You could also do this with a script on a vMA that has the vCenter server targeted. Basically if it returns something it found it installed, and if it doesn’t return anything, it’s not.

[code language=”bash”] #!/bin/bash

# run this script from vMA in this fashion: ./script.sh [vCenter Server] [file with on ESXi host on each line]

# validate that input has two parameters
if [ $# -ne 2 ]; then
echo "$0 [VCENTER] [HOSTS_FILE]"
exit 1
fi

# assign input args and username
VCENTER_HOST=$1
HOSTLIST=$2
export VI_USERNAME=root

# target vCenter server
source /opt/vmware/vma/bin/vifptarget -s ${VCENTER_HOST} > /dev/null 2>&1
echo -n "Now connected to: "
source /opt/vmware/vma/bin/vifptarget -d

# take inputs interactively
read -p "Enter VIB name: " VIB_NAME

# show hosts to operate on
echo "Checking VIB on :"
cat $HOSTLIST

# SCP software, then install
if [ $? -eq 0 ]; then
IFS=$’n’ #one host to a line in the .txt file
for VI_HOST in $(cat ${HOSTLIST});
do
echo "Checking VIB for ${VI_HOST}…"
esxcli –server ${VI_HOST} software vib list | grep -i $VIB_NAME
echo
done
unset IFS
else
echo "Unable to intialize check.}"
fi

echo "Check process complete."
[/code]

I’d really like to find the most elegant way to do this check. Please weigh in if you have ideas!

VMware powercli, VIB

James Green is an enterprise IT consultant, a product of an amazing IT community, and a partner in ActualTech Media. He is a serial vExpert designee and a passionate Tech Field Day delegate and supporter. » Read Full Bio...

James Green: View My Blog Posts

Copyright © 2023 · Monochrome Pro on Genesis Framework · WordPress · Log in

Posting....