Skip to content

Instantly share code, notes, and snippets.

@dansmith65
Last active June 20, 2024 10:23
Show Gist options
  • Save dansmith65/7dd950f183af5f5deaf9650f2ad3226c to your computer and use it in GitHub Desktop.
Save dansmith65/7dd950f183af5f5deaf9650f2ad3226c 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
@SomeCallMeTom
Copy link

SomeCallMeTom commented Dec 6, 2021

Fork of gist

Please consider updating

@dansmith65
Copy link
Author

@SomeCallMeTom Thanks for the enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment