I was looking at a way to compare versions of VDAs installed on various systems to see what systems needed to be updated. I ran into some issues trying to compare the versions as there are different formats and there was not a consistent numbering system going back to 7.15 that I could discern. So with some assistance from https://www.linkedin.com/in/douglas-ruehrwein-56835869/
, I was able to get the version check working correctly. This ended up comparing to the target version and returning anything that was less than the target version. I didn’t want to target anything newer than the target as I had reasons for those particular systems to be running a newer VDA. You can combine this with the VDA upgrade script to output the DNSNames of the machines to upgrades machines outside of the target version.
# Script to get VDA versions below target version. This was done in PowerShell ISE 5.1 against 1912LTSRCU5 DDCs.
$adminAddress = "deliverycontroller.fqdn"
$date = Get-Date -Format MMddyyyy
$outputName = "VDAToUpgrade"
$report = @()
[System.Version]$targetVersion = "1912.0.5000.5174"
$getMachines = Get-BrokerMachine -AdminAddress $adminAddress -MaxRecordCount 1000000
foreach($machine in $getMachines){
$line = "" | Select HostedMachineName, DNSName, AgentVersion, WillBeUpgraded
$testVersion = $machine.AgentVersion
$line.HostedMachineName = $machine.HostedMachineName
$line.DNSName = $machine.DNSName
$line.AgentVersion = $machine.AgentVersion
if([System.Version]$testVersion -ge [System.Version]($targetVersion)){
$line.WillBeUpgraded = "Current Version Or Newer"
}
if([System.Version]$testVersion -lt [System.Version]($targetVersion)){
$line.WillBeUpgraded = "Yes"
}
$report += $line
}
$report | Export-Csv -Path c:\scripts\logs\$date-$outputName.csv -Append -NoTypeInformation
# To see only the versions that are not matching the target version
$report | Where-Object WillBeUpgraded -eq "Yes"