#--------no modules
Try {
If (!(Test-Path C:\Temp)) {
New-Item -Path C:\Temp -ItemType Directory -ErrorAction SilentlyContinue | Out-Null
}
}
Catch {
Write-Warning "This is a windows only script or C:\Temp Directory can't be used / created"
Break Script
}
$current = $null
$latest = $null
$newCurrent = $null
$resultsarray = @()
$GamCheck = $null
Try {
Test-Path C:\GAMADV-XTD3\
$GamCheck = invoke-command -ScriptBlock { C:\GAMADV-XTD3\gam.exe version checkrc }
}
Catch {
Write-Warning "Go to
https://github.com/taers232c/GAMADV-XTD3/releases and download the current GAM and then install GAM in C:\GAMADV-XTD3\"
$filename = 'C:\Temp\Gaminstall.csv'
$resultsarray = [PSCustomObject]@{
'Install_GAMADV-XTD3' = "
https://github.com/taers232c/GAMADV-XTD3/releases"
DirectoryForXTD3NeedsToBe = 'C:\GAMADV-XTD3\'
}
$resultsarray | Export-Csv $filename -NoTypeInformation | Format-Table text-align=left -AutoSize
$GamCheck = $null
}
If ($GamCheck) {
$current = $GamCheck.split(":")[19].Trim()
$latest = $GamCheck.split(":")[21].Trim()
If ($LASTEXITCODE -eq 1) {
Try {
$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"
$filename = 'C:\Temp\Gamupgraded.csv'
$NeedUpGradeCode = $LASTEXITCODE
$GamCheck = $null
$GamCheck = invoke-command -ScriptBlock { C:\GAMADV-XTD3\gam.exe version checkrc }
$newCurrent = $GamCheck.split(":")[19].Trim()
$resultsarray = [PSCustomObject]@{
CurrentVersion = $current
LatestVersion = $latest
NeedUpgradeCode = $NeedUpGradeCode
Upgraded = $true
NewCurrent = $newCurrent
AfterUpgradeCode = $LASTEXITCODE
}
write-host "Version upgraded $latest" -ForegroundColor Blue
write-host "$resultsarray" -ForegroundColor Blue
$resultsarray | Export-Csv $filename -NoTypeInformation | Format-Table text-align=left -AutoSize
}
Catch {
Write-Warning "Problem with site or command. Maybe go to
https://github.com/taers232c/GAMADV-XTD3/releases and download the current GAM and then install GAM in C:\GAMADV-XTD3\ again"
$filename = 'C:\Temp\Gaminstall.csv'
$resultsarray = [PSCustomObject]@{
'Install_GAMADV-XTD3' = "
https://github.com/taers232c/GAMADV-XTD3/releases"
DirectoryForXTD3NeedsToBe = 'C:\GAMADV-XTD3\'
unknownError = $true
Error = $LASTEXITCODE
Upgraded = $False
}
$resultsarray | Export-Csv $filename -NoTypeInformation | Format-Table text-align=left -AutoSize
}
}
Else {
$filename = 'C:\Temp\GamCurrent.csv'
$resultsarray = [PSCustomObject]@{
CurrentVersion = $current
LatestVersion = $latest
Error = $LASTEXITCODE
Upgraded = $false
}
write-host "Gam version is current $current" -ForegroundColor Green
write-host "$resultsarray" -ForegroundColor Green
$resultsarray | Export-Csv $filename -NoTypeInformation | Format-Table text-align=left -AutoSize
}
}
Return $filename