Skip to main content

Installing a package with winget

What

winget is a command line tool to manage applications on the Windows 10 and 11 platform.

When/Why

We'll certainly want to use winget to push software to our devices, and we can do that rather nicely in a FileWave fileset/payload.

Similarly to other platforms where installs are coming directly from a CDN source, any software installed in this method will bypass FileWave boosters since the content is coming straight from the internet.

How

In our previous article, we looked at how we can find and uniquely identify a specific package to install (here).  And we also covered in an earlier document the special considerations for running winget through FileWave (here).  And once we have those building blocks in place, it is rather simple to install an application, as you'll see in the last line below:

# Get the path to winget.exe
$winget = (Get-ChildItem -Path "C:\Program Files\WindowsApps\" -Filter "winget.exe" -Recurse | Sort-Object -Property LastWriteTime | Select-Object -Last 1).FullName

# Get the directory that winget.exe is inside of
$wingetdir = Split-Path -Path $winget -Parent

# we change directory to this locale so we can run the winget command without the full path
cd $wingetdir

# adding the authorization acceptance here is superfluous if it has already been accepted, but it won't harm anything to include
# the "scope" defines that the install is for the device, and not just for current user
# "silent" is the default option, but we'll specify that as well for good measure
.\winget.exe install --exact --id Mozilla.Firefox --accept-package-agreements --accept-source-agreements --source winget --scope machine --silent

Our example here is simple, but there are lots of options available for the winget install command.  You'll find Microsoft's detailed reference here. (--version may be of particular interest...and on the surface --silent seems important, but since we run in SYSTEM account no progress indicator is shown anyway).

Note that the Fileset/Payload log file shows a nice amount of detail:

winget log.png

For troubleshooting purposes, the verbose logging options are very helpful.  You'll find information on --verbose-logs within the Microsoft reference here: https://docs.microsoft.com/en-us/windows/package-manager/winget/install  and this flag is the same for the upgrade command as well.