Skip to content

Instantly share code, notes, and snippets.

@schittli
Last active August 10, 2022 17:33
Show Gist options
  • Save schittli/40d80624476ea92ca95a82bcea7482e3 to your computer and use it in GitHub Desktop.
Save schittli/40d80624476ea92ca95a82bcea7482e3 to your computer and use it in GitHub Desktop.
Download-Tom-Chocolatey-Tools.ps1 #PowerShell #Choco
# Important:
# Obsolete. The latest version is here:
# https://gitlab.com/jig-opensource/source-code/scripts/-/tree/main/PowerShell/Chocolatey
# Downloads Tom-Chocolatey-Tools.ps1
# from GitLab into the current Dir
#
#
#
# 001, 220803
# gitlab-opensource@jig.ch
### Config
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
$TomChocolateyTools_ps1 = 'Tom-Chocolatey-Tools.ps1'
$TmpDlFile = 'Tom-Chocolatey-Tools.ps1-Download'
$SrcUrl = 'https://gitlab.com/jig-opensource/source-code/chocolatey/-/raw/main/Tom-Chocolatey-Tools.ps1'
### Prepare
$TomChocolateyTools_ps1 = Join-Path $ScriptDir $TomChocolateyTools_ps1
$TmpDlFile = Join-Path $ScriptDir $TmpDlFile
### Main
# Delete $TmpDlFile
$TmpDlFile | ? { Test-Path -LiteralPath $_ -PathType Leaf } | % {
Remove-Item -LiteralPath $_ -Recurse -Force -ErrorAction SilentlyContinue
}
# DL File
Invoke-WebRequest $SrcUrl | Select-Object -ExpandProperty Content | Out-File $TmpDlFile
If (Test-Path -LiteralPath $TmpDlFile -PathType Leaf) {
Remove-Item -LiteralPath $TomChocolateyTools_ps1 -Recurse -Force -ErrorAction SilentlyContinue
Move-Item $TmpDlFile $TomChocolateyTools_ps1
}
If ( $VerbosePreference -eq 'SilentlyContinue') {
Write-Host "Downloaded: $([IO.Path]::GetFileName($TomChocolateyTools_ps1))"
} Else {
Write-Host "Downloaded:`n$TomChocolateyTools_ps1"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment