Download and install the latest version of 5 base applications

An acquaintance saw my MECM lab environment the other day and saw how I was automatically downloading the latest versions of some applications (which were then automatically distributed and installed on the client computers), and thought it looked “cool”.
My acquaintance does not run MECM, or similar systems. But wanted me to show how he could automatically download and install latest version of some base applications.
So, I took my scripts and tweaked them for my acquaintance. Which then I thought I’d post them here (because it’s been ages since I posted anything).

Here you go, 5 applications that download and install automatically.

7-Zip

# 7-Zip
$7ZipDir = "C:\tmp\Latest\Apps\"
$dlurl = 'https://7-zip.org/' + (Invoke-WebRequest -Uri 'https://7-zip.org/download.html' | Select-Object -ExpandProperty Links | Where-Object {($_.innerHTML -eq 'Download') -and ($_.href -like "a/*") -and ($_.href -like "*x64.msi")} | Select-Object -First 1 | Select-Object -ExpandProperty href)
# above code borrowed from: https://perplexity.nl/windows-powershell/installing-or-updating-7-zip-using-powershell/
$installerPath = Join-Path $7ZipDir (Split-Path $dlurl -Leaf)
Invoke-WebRequest $dlurl -OutFile $7ZipDir\7z-x64.msi
Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"$7ZipDir\7z-x64.msi`" /qn ALLUSERS=2 REBOOT=REALLYSUPPRESS" -Wait -PassThru

# Google Chrome

# Google Chrome
$ChromeDir = "C:\tmp\Latest\Apps\GoogleChromeStandaloneEnterprise64.msi"
Invoke-WebRequest -Uri "http://dl.google.com/edgedl/chrome/install/GoogleChromeStandaloneEnterprise64.msi" -OutFile $ChromeDir
Start-Process msiexec.exe -Wait -ArgumentList '/I $ChromeDir /qn ALLUSERS=2 REBOOT=REALLYSUPPRESS'
Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"C:\tmp\Latest\Apps\GoogleChromeStandaloneEnterprise64.msi`" /qn ALLUSERS=2 REBOOT=REALLYSUPPRESS" -Wait -PassThru

Microsoft PowerShell 7

# Microsoft PowerShell 7
$metadata = Invoke-RestMethod https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/metadata.json
$release = $metadata.ReleaseTag -replace '^v';"https://github.com/PowerShell/PowerShell/releases/download/v${release}/PowerShell-${release}-win-x64.msi"
#above code borrowed from: Ruckzuck.tools
$PowerShellDir = "C:\tmp\Latest\Apps\PowerShell-7-win-x64.msi"
Invoke-WebRequest -Uri "https://github.com/PowerShell/PowerShell/releases/download/v${release}/PowerShell-${release}-win-x64.msi" -OutFile $PowerShellDir
Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"C:\tmp\Latest\Apps\PowerShell-7-win-x64.msi`" /qn ALLUSERS=2 REBOOT=REALLYSUPPRESS" -Wait -PassThru

Mozilla Firefox

# Mozilla Firefox
$FirefoxDir = "C:\tmp\Latest\Apps\FirefoxSetup.msi"
Invoke-WebRequest -Uri "https://download.mozilla.org/?product=firefox-msi-latest-ssl&os=win64&lang=en-US" -OutFile $FirefoxDir
Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"C:\tmp\Latest\Apps\FirefoxSetup.msi`" /qn" -Wait -PassThru

Notepad++

# Notepad++
$NotepadDir = 'C:\tmp\Latest\Apps\'
$href = ((Invoke-WebRequest -Uri 'https://notepad-plus-plus.org/downloads/').Links | Where-Object { $_.innerText -match 'current version' }).href
$downloadUrl = ((Invoke-WebRequest "https://notepad-plus-plus.org/$href").Links | Where-Object { $_.innerHTML -match 'installer' -and $_.href -match 'x64.exe' }).href
Invoke-RestMethod $downloadUrl -OutFile "$NotepadDir\npp.installer.x64.exe"
Start-Process -FilePath "$NotepadDir\npp.installer.x64.exe" -ArgumentList "/S" -PassThru

 

Psst, are you using Microsoft 365? Don’t miss out my old blog post, Microsoft 365 Apps (Office 365) hantering i MECM (SCCM)

 

#7-Zip, #GoogleChrome, #MicrosoftPowerShell7, #MozillaFirefox, #Notepad++, #Microsoft365Apps