Shorten the download code

This commit is contained in:
WindowsAddict 2024-10-20 03:27:40 +05:30
parent 38ee7853f1
commit b9ebf5b401

View File

@ -10,23 +10,25 @@ write-host
# Enable TLSv1.2 for compatibility with older clients for current session # Enable TLSv1.2 for compatibility with older clients for current session
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$DownloadURL1 = 'https://raw.githubusercontent.com/massgravel/Microsoft-Activation-Scripts/52d4c52dba8e29a3c1fb295c8946dbe6cf2f0239/MAS/All-In-One-Version-KL/MAS_AIO.cmd' $URLs = @(
$DownloadURL2 = 'https://dev.azure.com/massgrave/Microsoft-Activation-Scripts/_apis/git/repositories/Microsoft-Activation-Scripts/items?path=/MAS/All-In-One-Version-KL/MAS_AIO.cmd&versionType=Commit&version=52d4c52dba8e29a3c1fb295c8946dbe6cf2f0239' 'https://raw.githubusercontent.com/massgravel/Microsoft-Activation-Scripts/52d4c52dba8e29a3c1fb295c8946dbe6cf2f0239/MAS/All-In-One-Version-KL/MAS_AIO.cmd',
$DownloadURL3 = 'https://git.activated.win/massgrave/Microsoft-Activation-Scripts/raw/commit/52d4c52dba8e29a3c1fb295c8946dbe6cf2f0239/MAS/All-In-One-Version-KL/MAS_AIO.cmd' 'https://dev.azure.com/massgrave/Microsoft-Activation-Scripts/_apis/git/repositories/Microsoft-Activation-Scripts/items?path=/MAS/All-In-One-Version-KL/MAS_AIO.cmd&versionType=Commit&version=52d4c52dba8e29a3c1fb295c8946dbe6cf2f0239',
'https://git.activated.win/massgrave/Microsoft-Activation-Scripts/raw/commit/52d4c52dba8e29a3c1fb295c8946dbe6cf2f0239/MAS/All-In-One-Version-KL/MAS_AIO.cmd'
$URLs = @($DownloadURL1, $DownloadURL2, $DownloadURL3) )
$ShuffledURLs = $URLs | Sort-Object { Get-Random }
foreach ($URL in $URLs | Sort-Object { Get-Random }) {
try { try {
$response = Invoke-WebRequest -Uri $ShuffledURLs[0] -UseBasicParsing $response = Invoke-WebRequest -Uri $URL -UseBasicParsing
break
} }
catch { catch {
try { # Do nothing
$response = Invoke-WebRequest -Uri $ShuffledURLs[1] -UseBasicParsing
} }
catch {
$response = Invoke-WebRequest -Uri $ShuffledURLs[2] -UseBasicParsing
} }
if ($null -eq $response) {
Write-Warning "Failed to retrieve MAS from any of the available repositories, aborting!`n`nHelp - https://massgrave.dev/troubleshoot"
return
} }
# Verify script integrity # Verify script integrity