Last active
June 26, 2022 21:30
-
-
Save justusiv/1ff2ad273cea3e33ca4acc5cab24c8e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#requires -version 2 | |
<# | |
.SYNOPSIS | |
Installs latest rclone | |
.INPUTS | |
-Location to install. | |
-exeonly If you only want to deal with the exe. | |
-Temp Location to use for temp. | |
-beta To download the latest beta | |
.OUTPUTS | |
Outputs rclone version for verification | |
.NOTES | |
Author:JustusIV | |
.EXAMPLE | |
install-rclone -location "$env:USERPROFILE\Desktop" | |
install-rclone -location "c:\rclone" -execonly $true -temp "c:\mytemp" -beta $true | |
#> | |
Add-Type -AssemblyName System.IO.Compression.FileSystem | |
function Unzip{ | |
param([string]$zipfile, [string]$outpath) | |
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath) | |
} | |
Function Test-write{ | |
param ( | |
[Parameter(Mandatory=$True,Position=1)] | |
[string]$path) | |
$random = -join ((48..57) + (65..90) + (97..122) | Get-Random -Count 25 | % {[char]$_}) | |
try{"TESTWRITE" | Out-File -FilePath $path\$random -ErrorAction SilentlyContinue}catch{} | |
$wrote = (Test-Path $path\$random -ErrorAction SilentlyContinue) | |
if ($wrote){Remove-Item $path\$random -ErrorAction SilentlyContinue;return $true}else{return $false} | |
} | |
Function install-rclone{ | |
param ([Parameter(Position=1)] | |
[string]$location="c:\windows\system32", | |
[Parameter(Mandatory=$false)] | |
[boolean]$exeonly=$true, | |
[string]$temp=$env:TEMP, | |
[boolean]$beta=$true) | |
if (!(Test-write $location)){write-warning "Unable to write to location.";return} | |
if (!(Test-write $temp)){write-warning "Unable to write to temp location.";return} | |
if ([IntPtr]::Size -eq 8){$64 = $true} | |
if(($64) -and ($beta)){$url = "https://beta.rclone.org/rclone-beta-latest-windows-amd64.zip"} | |
elseif (($64) -and (!($beta))){$url = "https://downloads.rclone.org/rclone-current-windows-amd64.zip"} | |
elseif ((!($64)) -and (($beta))){$url = "https://beta.rclone.org/rclone-beta-latest-windows-386.zip"} | |
elseif ((!($64)) -and (!($beta))){$url = "https://downloads.rclone.org/rclone-current-windows-386.zip"} | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
Invoke-WebRequest -Uri $url -OutFile "$temp\rclone-windows.zip" | |
Unzip "$temp\rclone-windows.zip" "$temp\rclone-windows" | |
$items = (Get-ChildItem (Get-ChildItem "$temp\rclone-windows").FullName) | |
if ($exeonly){foreach ($item in $items | Where-Object {($_.name -eq "rclone.exe") -or ($_.name -eq "rclone")}){Move-Item $item.FullName -Destination $location -Force}}else{ | |
foreach ($item in $items){Move-Item $item.FullName -Destination $location -Force}} | |
Remove-Item $temp\rclone-windows -Recurse | |
Remove-Item $temp\rclone-windows.zip | |
Move-Item $location\rclone $location\rclone.exe -Force -ErrorAction SilentlyContinue | |
& $location\rclone.exe --version -q | |
} |
Is it possible to change the links to https?
The HTTP links redirect to HTTPS and powershell don't support redirects HTTP to HTTPS: PowerShell/PowerShell#2896
Is it possible to change the links to https?
The HTTP links redirect to HTTPS and powershell don't support redirects HTTP to HTTPS: PowerShell/PowerShell#2896
I added the 's' on the end of the http for the links. did one quick test and it worked but it wasn't thorough. Thanks for pointing this out.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@abarber229
install-rclone -beta $false
installs the latest stable version.
PS C:\WINDOWS\system32> install-rclone -beta $false
rclone v1.49.3
I do see that the latest beta is not being grabbed. My script grabs it from the location
http://beta.rclone.org/rclone-beta-latest-windows-amd64.zip which the contents are not correct even though the modified date is being updated.
So we will need to have the rclone team clean that up.
EDIT
did they change how the betas work?
EDIT2
made a post over on the git
rclone/rclone#3570