Skip to content

Instantly share code, notes, and snippets.

@SomeCallMeTom
Forked from dansmith65/Install-7zip.ps1
Last active March 4, 2024 22:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save SomeCallMeTom/6dd42be6b81fd0c898fa9554b227e4b4 to your computer and use it in GitHub Desktop.
Save SomeCallMeTom/6dd42be6b81fd0c898fa9554b227e4b4 to your computer and use it in GitHub Desktop.
Install latest version of 7-zip via PowerShell
$dlurl = 'https://7-zip.org/' + (Invoke-WebRequest -UseBasicParsing -Uri 'https://7-zip.org/' | Select-Object -ExpandProperty Links | Where-Object {($_.outerHTML -match 'Download')-and ($_.href -like "a/*") -and ($_.href -like "*-x64.exe")} | Select-Object -First 1 | Select-Object -ExpandProperty href)
# modified to work without IE
# above code from: https://perplexity.nl/windows-powershell/installing-or-updating-7-zip-using-powershell/
$installerPath = Join-Path $env:TEMP (Split-Path $dlurl -Leaf)
Invoke-WebRequest $dlurl -OutFile $installerPath
Start-Process -FilePath $installerPath -Args "/S" -Verb RunAs -Wait
Remove-Item $installerPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment