Whether you've just bought a new Windows 11 PC or you've had to start fresh on your existing one, it can be a hassle to get everything set up how you like it again. Installing all your apps is a particularly painful task, though thankfully, it can be made easier with the Windows Package Manager, or Winget.
In the past, I've talked about how you can export your app list to then import it with winget, but that requires setting up all the apps beforehand so you can export them. But there's an even easier way to install all your apps in one go with Winget and PowerShell scripting. I've made my own simple script for installing all your apps
Understanding the Winget script
It's fairly simple
The script I'm using to install my apps is heavily based on this template by GitHub user dougwaldron, and it's very straightforward. Here's what my script looks like:
As you can tell, my list of apps is relatively short, but you can make it as long as you need to without any drawbacks. There are two main parts to this script. First, we define the $apps variable as a list of items, which are then listed below it. Each item is listed as the name of a package on the official Winget repository. It's important that this name is correct so that apps can be installed.
Then, we use the Foreach function to define each item on the list as the variable $app. Using this variable, the script then searches for the package name among the apps installed on your system, and if it doesn't find a match, it runs the winget install command to install said package. If the package is found on your system, the command is skipped and the whole process is repeated for the next item on the list.
The script already attempts to run all the installers silently, so you run the script, you don't have to stay at your computer. The whole installation process happens in the background without requiring input from you, so you can do something else while you wait.
Modifying the script
Choose the apps you want
The somewhat short list of apps I use on my script is probably not going to work for everyone, but thankfully, it's very easy to change this to make it useful for your specific needs. Start by copying the text I linked above and pasting it into a blank Notepad file.
The second portion of the script never needs to be changed, since all it's doing is running the installation scripts based on the list you provided in the first portion. As such, all you need to do here is make changes to the list itself, and it's as easy as removing or adding new lines in the same style.
Say, for example, you don't use Nextcloud, but you do want to install the Google Drive desktop sync client. You can take the line that says:
@{Nextcloud.NextcloudDesktop}, And replace it with
@{Google.GoogleDrive}, You can copy and paste additional lines and then modify them for the apps you want. To find out the right package name for the app you want to install, you can run winget search [name] in Windows Terminal to find the exact package name, then copy that and paste it inside the curly brackets to add that app to the package list. Just make sure every item has a comma after it, except the last one on the list (yes, I did make that mistake while setting this up).
Because this is a PowerShell script, you can also make certain items on the list go unused if, for whatever reason, you don't want a specific app to be installed on a given computer, but want to keep it readily available. Simply adding a # (pound sign) at the beginning of a line will make it so that item isn't interpreted, and you can easily remove it later when you want that specific app to be installed on a different PC.
Once you've made your changes, you can save the file with any name you prefer, as long as there are no spaces — just make sure you add .ps1 at the end of the file name, and set the file type to All types before saving.
Why use this method?
It's a good bit easier
As I mentioned at the top, Winget also offers an export feature that you can use to create lists of apps that you can then import on a new machine, so you may be wondering how this is different. Truthfully, the differences aren't huge, but there are some benefits to doing it this way.
The biggest one is that you don't need to install any of the apps you want to include on the list. All you need is to know the package names and them into the file with the appropriate formatting, which makes things a good bit easier. The PowerShell script also has a simpler structure than the winget export file, so modifying it is a little bit easier. Adding or removing apps from the list is much easier this way, plus you can easily use the pound sign to mark specific items as unused for a given instance without having to remove them from the file entirely.
It's also easier to run a PowerShell script than to use the winget import command. In many cases, you should be fine just right-clicking the script file in File Explorer and then choosing Run with PowerShell, so it's a bit simpler. Sometimes, you may want to have administrator permissions, in which case you need to launch PowerShell with admin permissions first, then enter the path to the file (the path should contain no spaces) and press Enter. That's still somewhat easier than using the winget import command.
All you need to keep in mind here is that Winget needs to be installed. Windows 11 includes it by default, but if you used a custom or modified ISO, you may not have it, so you'll need to head to the Microsoft Store to get it. Still, that's unlikely to affect the majority of people.
Make it easier to set up your PC
All in all, this script is a great way to make things easier on yourself when setting up a new PC, and it will save you a lot of time if this is something you do semi-regularly. You can always keep this script file on a server for a rainy day, so you can use it later and even update it over time as your habits change. Winget has made all kinds of things much easier for Windows users, and taking advantage of these features can greatly change your perception of the user experience.
