Ah, thanks for the heads up, and the mention! It looks like the last closing curly brace was hidden under the 3 dots in Google Groups, apparently it thinks it's part of a signature or something.
Here's the code again, but slightly updated. This code block shows all of the changes between the old version and the updated version, so you can easily see what has changed. This won't help if you have the script run via a scheduled task (as it will update in the background and you won't see the output); I prefer to update manually in case I have a GAM script that needs to run overnight or something. The output will also be overwhelming if you're updating from a rather old version as well. :)
if (.\gam version checkrc) {
$dlurl = ($releases[0].assets | where {$_.name -like "*windows*64.zip"}).browser_download_url
$dir = (Get-Location).Path
(new-object System.Net.WebClient).DownloadFile($dlurl, "$dir\gamadv-xtd3-latest-windows-x86_64.zip")
$oldchangeloglinescount=(Get-Content .\GamUpdate.txt | Select-String .*).count
Expand-Archive "$dir\gamadv-xtd3-latest-windows-x86_64.zip" "$dir\" -Force
mv "$dir\gamadv-xtd3\*" "$dir\" -Force
rm "$dir\gamadv-xtd3\"
$newchangeloglinescount=(Get-Content .\GamUpdate.txt | Select-String .*).count
Get-Content .\GamUpdate.txt -Head ($newchangeloglinescount-$oldchangeloglinescount-1)
} else {
# Nothing, GAM is already up-to-date
}
The changelog is stored in the GamUpdate.txt file. The updated script gets the number of lines in the old GamUpdate file and the new one, subtracts them to get the count of new lines added, then reads this number of lines in that file to the console.
For Linux users, I use this bash script to update GAM (and display the changelog):
oldchangeloglinescount=$(wc -l ~/bin/gamadv-xtd3/GamUpdate.txt | awk '{print $1;}')
newchangeloglinescount=$(wc -l ~/bin/gamadv-xtd3/GamUpdate.txt | awk '{print $1;}')
GREEN='\033[0;32m'
NC='\033[0m' # No Color
printf "${GREEN}This update includes the following changes:${NC}\n"
head -n $(($newchangeloglinescount - $oldchangeloglinescount)) ~/bin/gamadv-xtd3/GamUpdate.txt
Hopefully some others find that helpful, and hopefully with this last sentence here Google Groups won't hide any lines from the above scripts. :)