Skip to content

Instantly share code, notes, and snippets.

@elpatron68
Last active June 7, 2022 09:36
Show Gist options
  • Save elpatron68/45780b2ebee88f887d7f3464004d4dc3 to your computer and use it in GitHub Desktop.
Save elpatron68/45780b2ebee88f887d7f3464004d4dc3 to your computer and use it in GitHub Desktop.
Download latest AutoDrive and Courseplay from Github
# Downloads latest version of the Farming Simulator mods Courseplay and AutoDrive
# (c) 2022 elpatron68
# https://github.com/elpatron68
#
# To run this script, create a desktop shortcut like this:
# C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -ExecutionPolicy Bypass -File "<full path to this script>"
$docs = [Environment]::GetFolderPath("MyDocuments")
$fs22modpath = Join-Path -Path $docs -ChildPath "My Games\FarmingSimulator2022\mods"
$CPrepo = "Courseplay/Courseplay_FS22"
$CPfile = "FS22_Courseplay.zip"
$ADrepo = "Stephan-S/FS22_AutoDrive"
$ADfile = "FS22_AutoDrive.zip"
# Download latest version from Github
function DownloadLatestRelease{
param($repo, $file, $name)
$releases = "https://api.github.com/repos/$repo/releases"
$ProgressPreference = 'SilentlyContinue'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$tag = (Invoke-WebRequest -Uri $releases -UseBasicParsing | ConvertFrom-Json)[0].tag_name
$published = (Invoke-WebRequest -Uri $releases -UseBasicParsing | ConvertFrom-Json)[0].published_at
Write-Host "Latest version: $tag, published at $published"
$download = "https://github.com/$repo/releases/download/$tag/$file"
Write-Host "Dowloading latest release from $download"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest $download -Out "$fs22modpath\$file"
}
Write-Host "FS22 AutoDrive/Courseplay Mod Update Script (FACMUS)"
if (Test-Path -Path $fs22modpath) {
Write-Host Starting Courseplay update...
DownloadLatestRelease $CPrepo $CPfile "Courseplay" $fs22modpath
Write-Host Starting AutoDrive update...
DownloadLatestRelease $ADrepo $ADfile "AutoDrive" $fs22modpath
Write-Host Updates completed.
} else {
Write-Host FS22 mods directory does not exist, please check the path: $fs22modpath
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment