Skip to content

Instantly share code, notes, and snippets.

@Alistair1231
Last active April 22, 2023 10:55
Show Gist options
  • Save Alistair1231/b1d09807524a7c76d9551359df8ad690 to your computer and use it in GitHub Desktop.
Save Alistair1231/b1d09807524a7c76d9551359df8ad690 to your computer and use it in GitHub Desktop.
powershell script to get latest KMS_VL_ALL_AIO version
# ########
# # bash #
# ########
# pattern="KMS_VL_ALL_AIO-.*.7z"
# repo="abbodi1406/KMS_VL_ALL_AIO"
# # remove old files
# rm -f description.txt && rm -f ATLauncher-*.jar
# # get the files
# curl -s "https://api.github.com/repos/$repo/releases/latest" | grep -oP '"browser_download_url":\s*"\K[^"]+' | grep -E "$pattern" | wget -q --show-progress -i -
# # get the description
# curl -s "https://api.github.com/repos/$repo/releases/latest" | grep -oP '"body":\s*"\K[^"]+' | sed -e 's/\\r\\n/\n/g' -e 's/\\n/\n/g' -e 's/^[[:space:]]+//' | tr -d '```' > description.txt
##############
# powershell #
##############
$pattern="KMS_VL_ALL_AIO-.*.7z"
$repo="abbodi1406/KMS_VL_ALL_AIO"
# remove old files
if (Test-Path $pattern) { rm -Force $pattern }
if (Test-Path "description.txt") { rm -Force "description.txt" }
# get the files
(Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/releases/latest").assets.browser_download_url |
Select-String -Pattern $pattern |
ForEach-Object {
Invoke-WebRequest $($_ | Select-Object -ExpandProperty line) -OutFile $($_.Matches.Value.Split("/")[-1])
}
# get the description
Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/releases/latest" |
Select-Object -ExpandProperty body |
ForEach-Object {$_ -replace '\\r\\n', "`n" -replace '^[[:space:]]+', '' -replace '```', ''} |
Set-Content -Path "description.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment