Cloudy: With a chance of Winget

Cloudy: With a chance of Winget

This blog will be about my experience I had with Winget. Until now we only made use of Chocolatey but I was intrigued if Winget could be a good replacement. After reading some other blogs and information I decided to test it out myself.

Just like always I am going to divide this blog in. There are 8 parts.

  1. Background information
  2. Installing the App installer
  3. Installing/removing applications
  4. Upgrading applications
  5. Winget ADMX
  6. Troubleshooting Winget
  7. Upload your own Apps
  8. Deploy all the apps with the company app

1.Background Information

Just like Chocolatey, Winget is a  tool to manage packages (Package Manager) on your device. This utility gives you the possibility to automate the whole process of installing/removing/upgrading (updating)  packages (software) on the device. Just with the use of the command line or PowerShell you could automatically download the packages and install them on the device. When you have some experience with Linux you will be familiar with it but Windows users didn’t have this built-in functionality so they needed to use some 3 party software like Chocolatey. Luckily in 2020 Microsoft released their own packaging manager for Windows 10. But when it was released it was a little bit buggy in my opinion. But things have changed a little bit, so I wanted to take a closer look at it.

2.Installing the app installer (winget)

When you want to play around or just want to start migrating your chocolatey apps to Winget, you will need to make sure Winget is installed on the devices.

You have got multipe options to install Winget

  1. Install the App Package with Powershell
  2. Deploy the App installer from the Microsoft Store

1.Using PowerShell

You could call upon the invoke webrequest to download the app package file straight from the source. When it’s downloaded you can use the add-appxpackage to install it

Md c:\temp\

Invoke-WebRequest -Uri “https://github.com/microsoft/winget-cli/releases/download/v-0.2.10191-preview/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.appxbundle” -OutFile “C:\temp\WinGet.appxbundle”

Add-AppxPackage “C:\temp\WinGet.appxbundle”

2.Microsoft Store

If you don’t like to use a simple PowerShell script you could make sure The package manager is installed from within the Microsoft Store. But of course, you will need to make sure you have configured/synced the Microsoft store with your Microsoft 365 tenant.

When you have made sure the Microsoft store for business is connected you can click on the “Open the business store” to start searching

Search for Add the app installer package and install/order it.

When you have made sure the app is approved we can add the app to the company’s collection.

Don’t forget to sync and assign the app in Intune when you have added the app to the collection.

3.Installing and Removing applications

Installing Applications

Installing applications is done within a few seconds. If you want to get a list of all the applications you could install, just specify the “install” or “show” parameter and it will list all the packages out there.

Another possibility is just to open the browser and surf to

winget-pkgs/manifests at master · KaranKad/winget-pkgs (github.com)

Let’s proceed wit installing some applications/packages. So if you want to install 7zip, you will need to specify this command

winget install 7zip.zip (the ID).

But if you want to specify more apps at the same time, just use the ;

winget install 7zip.7zip  ;  winget install Mozilla.Firefox  – -force – – silent

Please Note:

Before installing applications, make sure you have taken a look at the settings in winget. Maybe you want to make sure the packages are installed for the entire machine instead of the current user?

This is my settings.json file which I tested Winget with

Removing Applications

Removing existing software is also very very easy. You will only need to specify the uninstall parameter and which apps need to be removed

It’s simple and it works just like it should and nothing more.

4.Upgrading applications

Just like with chocolatey you will get the possibility to update/upgrade apps. It’s very easy to upgrade the apps, you only need to specify the upgrade parameter and which app you want to update.

Or use the list option to check if a new version is available.

I guess I am going to like this winget update function a lot more in the feature than Chocolatey. Winget lists all applications which needed to be updated! Chocolatey only lists the applications which needed to be updated which chocolatey installed itself.

When you need to update all apps with winget just specify the upgrade  – -all parameter.

If you want to make sure your apps are upgraded each week you could create a PowerShell script and convert it to a Win32app. This script will create an additional PowerShell script and attach it to a task schedule.

$content = @'
winget upgrade --all --force
'@

 
# create custom folder and write PS script
$path = $(Join-Path $env:ProgramData CustomScripts)
if (!(Test-Path $path))
{
New-Item -Path $path -ItemType Directory -Force -Confirm:$false
}
Out-File -FilePath $(Join-Path $env:ProgramData CustomScripts\WingetUppgradeApps.ps1) -Encoding unicode -Force -InputObject $content -Confirm:$false
 
# register script as scheduled task
$Time = New-ScheduledTaskTrigger -AtLogOn
$User = "SYSTEM"
$Action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-ex bypass -file `"C:\ProgramData\CustomScripts\WingetUppgradeApps.ps1`""
Register-ScheduledTask -TaskName "UpgradeApps" -Trigger $Time -User $User -Action $Action -Force
Start-ScheduledTask -TaskName "UpgradeApps"

The only two things I am missing (for now) are:

1.Excluding applications.

When you have teams installed it will try to update teams…. And most of the times it will fail. Luckily when other programs needed to be updated it will just proceed even with the first installation error.

2.No applicable update found

And I guess that’s why I was mentioning: “I am going to like this update function” because for now a lot of already installed programs can not be upgraded! You will be prompted with: No applicable update found.

But when I remove the zoom 5.5.2 application first and reinstall the same version again with the parameter: winget install zoom.zoom – -version 5.5.2

I can upgrade it with no problem at all? that’s odd but I know it can be very difficult to make sure all the packages can be updated.

5.Winget ADMX

I guess I really love this one. Wignet even has its own ADMX files which you can use to limit some functions:

https://github.com/microsoft/winget-cli/releases/download/v1.0.11451/DesktopAppInstallerPolicies.zip

I guess when I am going to only use Winget, I will take some time to make sure you can ingest the ADMX in Intune.

6.Troubleshooting Winget installation errors

If you have the same luck as me, you always will directly end up with some troubleshooting. Don’t get me wrong, but I love when it fails at the first attempt… if al succeeds without errors, you don’t get the possibility to start troubleshoot it.

Luckily you will get a very nice log file, which I didn’t expected to be good…

Like I was telling with the upgrade – option,  upgrading teams is difficult. It’s not winget which is causing the problem.. it’s the teams installer.

I guess I have some experience with teams installers?

7.Building your own packages

If you wan to start building your own packages you will need to install the create module first: “Winget install wingetcreate”

After the module is installed you can just create a new package when you enter this command: wingetcreate new. It will ask you for the download url location of the installation file.

As an example, I specified the notepad + + exe download url

It will guide you to the whole process. It will ask you some default questions which need to be answered.

When you are almost done it will ask you to submit the package to your own repository and prompt you for your github credentials.

As shown above, I used the NotePad + + example, it’s already in the repository. Just within a minute I (of course) received a message that it’s already in the repository.  So I closed the pull request.

8.Deploy the apps with the company portal

Just like my blog about the Win32 PowerShell express and my blog about why you need to start loving the company portal. You can create all the installation packages from scratch and upload them to Intune with PowerShell

Conclusion:

When all the problems with winget are resolved you will need to start converting your Powershell/Chocolatey Win32 apps to Winget Applications.

I prefer to use a build-in utility over a third party tool but for now I will stick to Chocolatey. I hope I can update this blog in the near future to tell you I am migrating all packages to Winget

Leave a Reply

Your email address will not be published. Required fields are marked *

13  +    =  17