UpdateGithubDesktop.ps1
<#PSScriptInfo .VERSION 1.0.2 .GUID d393b38f-f1b8-4b2f-bda2-9a35301f80b2 .AUTHOR Fabrice Sanga .COMPANYNAME sangafabrice .COPYRIGHT © 2022 SangaFabrice. All rights reserved. .TAGS github-desktop nuget-package update github .LICENSEURI https://github.com/sangafabrice/reg-cli/blob/main/LICENSE.md .PROJECTURI https://github.com/sangafabrice/reg-cli/tree/githubdesktop .ICONURI https://rawcdn.githack.com/sangafabrice/reg-cli/8d1970259bf4c1e8fb25ab87ef8a9d3bf1bea990/icon.png .EXTERNALMODULEDEPENDENCIES DownloadInfo,RegCli .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES Add common script to updater script. Fix help-based comment. .PRIVATEDATA #> #Requires -Module @{ModuleVersion = '5.0.4'; ModuleName = 'DownloadInfo'} #Requires -Module @{ModuleVersion = '6.2.2'; ModuleName = 'RegCli'} [CmdletBinding()] Param ( [ValidateNotNullOrEmpty()] [ValidateScript({ Test-InstallLocation $_ $PSScriptRoot })] [string] $InstallLocation = "${Env:ProgramData}\GitHub Desktop", [ValidateNotNullOrEmpty()] [ValidateScript({ Test-InstallerLocation $_ })] [string] $SaveTo = $PSScriptRoot ) & { $NameLocation = "$InstallLocation\GithubDesktop.exe" Try { $UpdateModule = Import-CommonScript chrome-installer | Import-Module -PassThru -Force -Verbose:$False @{ UpdateInfo = $( Write-Verbose 'Retrieve install or update information...' Try { Get-DownloadInfo -From GithubDesktop } Catch { } ) NameLocation = $NameLocation SaveTo = $SaveTo SoftwareName = 'Github Desktop' InstallerDescription = 'Simple collaboration from your desktop' InstallerType = 'Squirrel' Verbose = $VerbosePreference -ine 'SilentlyContinue' } | ForEach-Object { Invoke-CommonScript @_ } } Catch { } Finally { $UpdateModule | Remove-Module -Verbose:$False } } <# .SYNOPSIS Updates GitHub Desktop software. .DESCRIPTION The script installs or updates GitHub Desktop on Windows. .NOTES Required: at least Powershell Core 7. .PARAMETER InstallLocation Path to the installation directory. It is restricted to file system paths. It does not necessary exists. It defaults to "%ProgramData%\GitHub Desktop". .PARAMETER SaveTo Path to the directory of the downloaded installer. It is an existing file system path. It defaults to the script directory. .EXAMPLE Get-ChildItem 'C:\ProgramData\GitHub Desktop' -ErrorAction SilentlyContinue PS > .\UpdateGithubDesktop.ps1 -InstallLocation 'C:\ProgramData\GitHub Desktop' -SaveTo . PS > Get-ChildItem 'C:\ProgramData\GitHub Desktop' | Select-Object Name -First 5 Name ---- locales resources swiftshader chrome_100_percent.pak chrome_200_percent.pak PS > Get-ChildItem | Select-Object Name Name ---- github_desktop_3.0.8.exe UpdateGithubDesktop.ps1 Install GitHub Desktop to 'C:\ProgramData\GitHub Desktop' and save its setup installer to the current directory. #> |