Skip to content

Instantly share code, notes, and snippets.

@dougwaldron
Last active September 12, 2024 21:07
Show Gist options
  • Save dougwaldron/d510f2d67a922da169aca1aeff7e4c4d to your computer and use it in GitHub Desktop.
Save dougwaldron/d510f2d67a922da169aca1aeff7e4c4d to your computer and use it in GitHub Desktop.
Install software with winget / automate installation with PowerShell
# 1. Make sure the Microsoft App Installer is installed:
# https://www.microsoft.com/en-us/p/app-installer/9nblggh4nns1
# 2. Edit the list of apps to install.
# 3. Run this script as administrator.
Write-Output "Installing Apps"
$apps = @(
@{name = "7zip.7zip" },
@{name = "Adobe.Acrobat.Reader.64-bit" },
@{name = "Axosoft.GitKraken" },
@{name = "Devolutions.RemoteDesktopManagerFree" },
@{name = "Dropbox.Dropbox" },
@{name = "Git.Git" },
@{name = "GnuPG.Gpg4win" },
@{name = "Google.Chrome" },
@{name = "Greenshot.Greenshot" },
@{name = "Inkscape.Inkscape" },
@{name = "JanDeDobbeleer.OhMyPosh" },
@{name = "JetBrains.Toolbox" },
@{name = "JohnMacFarlane.Pandoc" },
@{name = "KDE.KDiff3" },
# @{name = "Microsoft.AzureDataStudio" }, # Included with SSMS
@{name = "Microsoft.dotnet" },
@{name = "Microsoft.PowerShell" },
@{name = "Microsoft.PowerToys" },
@{name = "Microsoft.SQLServerManagementStudio" }, # Includes AzureDataStudio
@{name = "Microsoft.VisualStudio.2022.Community" },
@{name = "Microsoft.VisualStudioCode" },
@{name = "Microsoft.WindowsTerminal" },
@{name = "Mozilla.Firefox.DeveloperEdition" },
@{name = "Mozilla.Firefox" },
@{name = "NickeManarin.ScreenToGif" },
@{name = "Notepad++.Notepad++" },
@{name = "OpenJS.NodeJS.LTS" },
@{name = "TimKosse.FileZilla.Client" },
@{name = "VideoLAN.VLC" },
@{name = "WinDirStat.WinDirStat" },
@{name = "Zoom.Zoom" }
);
Foreach ($app in $apps) {
$listApp = winget list --exact -q $app.name
if (![String]::Join("", $listApp).Contains($app.name)) {
Write-host "Installing: " $app.name
winget install -e -h --accept-source-agreements --accept-package-agreements --id $app.name
}
else {
Write-host "Skipping: " $app.name " (already installed)"
}
}

Windows released a new command line tool in 2021 for installing software called winget. My verdict is: wow, it's really good!

Using this PowerShell script, within about 10 minutes it had installed over 30 applications with no interaction needed from me.

Here's a quick tutorial on using winget.

  • Winget comes pre-installed on new computers, but if you don't have it, just install the App Installer from the Microsoft Store.
  • winget list shows all applications you currently have installed and labels which ones are available through winget. This is a good way to prepare your own setup script, especially if you're planning to get a new computer.
  • winget search <name of app> to find out if an app you want can be installed through winget.
  • winget install and winget uninstall do exactly what you think.

You can install each app separately using those commands. Or if you want to use the script to automate it, here's how to do that:

  1. Edit the InstallSoftware.ps1 file to include the apps you want.
  2. Start PowerShell as administrator.
  3. If running scripts is blocked (it should be), you can temporarily unblock them with Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process.
  4. Run the script and enjoy!
@omijara
Copy link

omijara commented Jul 30, 2023

Hi Dougwaldron, Can I define application source path in winget, for example I have a app server in my private network, I want to link the IP with listed software inside the script so that it will install the listed software from my app server. If possible please give me the modify script. Thank you.

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