Created
January 4, 2025 14:29
-
-
Save baaamn/c8f43935841d6e9c4de2b3adc5734468 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Powershell One-Liner that downloads the latest Python-Version for Windows and asks if it should install it right away. It even opens an elevated sessions with admin rights. | |
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) { Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"$url = (Invoke-WebRequest -Uri 'https://www.python.org/downloads/windows/').Content | Select-String -Pattern 'https://www.python.org/ftp/python/\d+\.\d+\.\d+/python-\d+\.\d+\.\d+-amd64\.exe' -AllMatches | % { `$_.Matches[0].Value }; $path = `$env:USERPROFILE\Downloads\ + (`$url -split '/')[-1]; Invoke-WebRequest -Uri `$url -OutFile $path; if ((Read-Host 'Install? (Y/N)') -ieq 'y') { Start-Process -FilePath $path -Wait }`"" -Verb RunAs } else { $url = (Invoke-WebRequest -Uri 'https://www.python.org/downloads/windows/').Content | Select-String -Pattern 'https://www.python.org/ftp/python/\d+\.\d+\.\d+/python-\d+\.\d+\.\d+-amd64\.exe' -AllMatches | % { $_.Matches[0].Value }; $path = "$env:USERPROFILE\Downloads\" + ($url -split '/')[-1]; Invoke-WebRequest -Uri $url -OutFile $path; if ((Read-Host "Install? (Y/N)") -ieq 'y') { Start-Process -FilePath $path -Wait }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment