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:
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!