Advertisement
mlot

Cleed Powershell Update Download

Aug 27th, 2024 (edited)
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 2.54 KB | Source Code | 0 0
  1. <#PSScriptInfo
  2. .VERSION # 2024-08-28 (Beta)
  3. .AUTHOR mlot (sr.ht) / beevomit (github)
  4. .COPYRIGHT 2024
  5. .LICENSEURI https://opensource.org/licenses/MIT
  6. #>
  7. <#
  8. .SYNOPSIS
  9. Downloads the latest version of Cleed for Windows based on the system architecture saving it in the user profile "Downloads" folder.
  10. .NOTES
  11. https://github.com/radulucut/cleed
  12. Run "cleed --version" to check your current version against the latest available download.
  13. #>
  14.  
  15. function Get-CleedLastestVersion {
  16.     $url = 'https://github.com/radulucut/cleed/releases/latest'
  17.     $request = [System.Net.WebRequest]::Create($url)
  18.     $response = $request.GetResponse()
  19.     $realTagUrl = $response.ResponseUri.OriginalString
  20.     $version = $realTagUrl.split('/')[-1].Trim('v')
  21.     Return $version, $realTagUrl    
  22. }
  23.  
  24.  
  25. function Request-LatestCleedDownload {
  26.     param (
  27.         # Message about error/success to display in email body
  28.         [Parameter(Mandatory=$true)]
  29.         [string]
  30.         $realTagUrl
  31.     )
  32.  
  33.     $OsArchitecture = Get-SystemArchitecture
  34.     switch ($OsArchitecture) {
  35.         {$OsArchitecture -match "64-bit"} {$filename = "cleed_Windows_x86_64.zip"; break}
  36.         {$OsArchitecture -match "32-bit"} {$filename = "cleed_Windows_i386.zip"; break}
  37.         {$OsArchitecture -match "ARM64"} {$filename = "cleed_Windows_arm64.zip"; break}
  38.         Default {$filename = "cleed_Windows_x86_64.zip"; break}
  39.     }
  40.     $realDownloadUrl = $realTagUrl.Replace('tag', 'download') + '/' + $fileName
  41.     try {
  42.         Invoke-WebRequest -Uri $realDownloadUrl -OutFile $env:USERPROFILE/Downloads/$fileName -MaximumRedirection 9
  43.     } catch {
  44.         Write-Host -ForegroundColor Red "There was a problem downloading the latest version! Aborting..."
  45.         Exit(1)
  46.     }
  47.     Write-Host -ForegroundColor Green "Downloading complete."
  48.     Return $null
  49. }
  50.  
  51.  
  52. function Get-SystemArchitecture {
  53.     $Architecture = (Get-ComputerInfo).OsArchitecture
  54.     Return $Architecture
  55. }
  56.  
  57.  
  58. function Start-Main {
  59.     $LatestVersion,$DownloadURL = Get-CleedLastestVersion
  60.     Write-Host -ForegroundColor Cyan "Cleed Latest Version is: $LatestVersion"
  61.     $continueToDownload = Read-Host -Prompt "Do you want to download the latest version? (y/n)"
  62.     if ($continueToDownload -eq "y") {
  63.         Write-Host -ForegroundColor Green "Downloading latest version of Cleed for Windows..."
  64.         Request-LatestCleedDownload -realTagUrl $DownloadURL
  65.     } else {
  66.         Write-Host -ForegroundColor Red "Downloading aborted by user!"
  67.         Exit(1)
  68.     }
  69.     Return $null    
  70. }
  71.  
  72. Start-Main
  73.  
  74. Exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement