summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWindowsAddict2024-10-19 21:57:40 +0000
committerWindowsAddict2024-10-19 21:57:40 +0000
commitb9ebf5b4012d9bab84f99e267c014e90c2caaeca (patch)
tree7da9d798e6bd709d1604f5e31862cacbf55ff036
parent38ee7853f1bf72a7ea158a0103414e3ad1a65313 (diff)
downloadmassgrave.dev-b9ebf5b4012d9bab84f99e267c014e90c2caaeca.zip
Shorten the download code
-rw-r--r--static/get.ps126
1 files changed, 14 insertions, 12 deletions
diff --git a/static/get.ps1 b/static/get.ps1
index 6925598..32e1d08 100644
--- a/static/get.ps1
+++ b/static/get.ps1
@@ -10,25 +10,27 @@ write-host
# Enable TLSv1.2 for compatibility with older clients for current session
[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'
-$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'
-$DownloadURL3 = 'https://git.activated.win/massgrave/Microsoft-Activation-Scripts/raw/commit/52d4c52dba8e29a3c1fb295c8946dbe6cf2f0239/MAS/All-In-One-Version-KL/MAS_AIO.cmd'
+$URLs = @(
+ 'https://raw.githubusercontent.com/massgravel/Microsoft-Activation-Scripts/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 }
-
-try {
- $response = Invoke-WebRequest -Uri $ShuffledURLs[0] -UseBasicParsing
-}
-catch {
+foreach ($URL in $URLs | Sort-Object { Get-Random }) {
try {
- $response = Invoke-WebRequest -Uri $ShuffledURLs[1] -UseBasicParsing
+ $response = Invoke-WebRequest -Uri $URL -UseBasicParsing
+ break
}
catch {
- $response = Invoke-WebRequest -Uri $ShuffledURLs[2] -UseBasicParsing
+ # Do nothing
}
}
+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
$releaseHash = '39961D29B07D59D54A709AA7B152269ADC6349752660A0C66D627B09DF18B9B6'
$stream = New-Object IO.MemoryStream