I was recently asked if there was a quick way to find out how many vShield Edges were out-of-date and could be upgraded in a vCloud Director environment. I didn’t know of any, so I turned to my good friend PowerCLI and came up with this:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Adam Rush | |
# Created on: 2016-05-28 | |
# Finds all upgradeable vShield Edges and exports CSV file to Desktop | |
$reportPath = "$HOME\Desktop\upgradable-VSEs.csv" | |
$report = @() | |
Write-Host "Searching for all vShield Edges..." -ForegroundColor Yellow | |
$edges = Get-View -ViewType virtualmachine -Property Name,Config -Filter @{'Config.VAppConfig.Product[0].Name'='vShield Edge'} | % { | |
$edge = '' | Select 'Name','Version' | |
$edge.Name = $_.Name | |
$edge.Version = $_.config.vappconfig.product[0].version | |
$report += $edge | |
} | |
$highestVersion = ($report | Sort version -Descending)[0].version | |
Write-Host "Highest vShield Edge version: $highestVersion" -ForegroundColor Yellow | |
Write-Host "Exporting upgradeable vShield Edges..." -ForegroundColor Yellow | |
$upgradableVSEs = $report | Where {$_.version -lt $highestVersion} | |
Write-Host "Saving file to: $reportPath" -ForegroundColor Yellow | |
$upgradableVSEs | Export-Csv -NoTypeInformation -UseCulture -Path $reportPath |
This script does assume that at least one of the vShield Edges in your environment is up-to-date, as it looks for the highest available version deployed and not the known latest version.