This command $GamCheck = invoke-command -ScriptBlock { C:\GAMADV-XTD3\gam.exe version checkrc}
makes a string and inside that string are the current and latest version information.
GAMADV-XTD3 6.07.31 - https://github.com/taers232c/GAMADV-XTD3 - pyinstaller
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.9.7 64-bit final
Windows 10 10.0.18363 SP0 Multiprocessor Free AMD64
Path: C:\GAMADV-XTD3
Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, customer_id: C047encoi, domain: sonos.com
Version Check:
Current: 6.07.31
Latest: 6.07.31
I was getting the information like this
$current = $GamCheck.split(":")[20].Trim()
$latest = $GamCheck.split(":")[22].Trim()
recently this failed on different machines and I found that the number 20
and 22
in the lines above needed to be changed sometimes.
Is there a more reliable way to get the current and latest numbers only from that string ?
I need the latest number further down the script so I can download and install the update automatically.
$client = new-object System.Net.WebClient
$client.DownloadFile("https://github.com/taers232c/GAMADV-XTD3/releases/download/v$latest/gamadv-xtd3-$latest-windows-x86_64.msi", "C:\Temp\gamadv-xtd3-$latest-windows-x86_64.msi")
Start-Process -Filepath "C:\Temp\gamadv-xtd3-$latest-windows-x86_64.msi" -ArgumentList "/passive" -Wait | Wait-Process -Timeout 60
Remove-Item "C:\Temp\gamadv-xtd3-$latest-windows-x86_64.msi"