Winget, the new package manager for Windows, is revolutionizing software deployment by simplifying the process of installing and managing applications. PSAppDeployToolkit, a PowerShell module, further enhances this functionality by providing additional features for deploying Winget packages. This article will guide you through the process of using PSAppDeployToolkit to deploy Winget packages using Microsoft Intune, a cloud-based management service for Windows devices.

The Challenge to Deploy Winget in System Context

Winget is primarily designed for user-level applications, and it doesn't natively support system-level installations. But most users are (or at least should be) standard users without admin rights. But no admin often means insufficient rights to perform tasks like modifying system files or registry settings, which are often required for installing system-level applications.

To overcome this limitation, we need to resolve the path to the winget.exe to use it in system context.
Which can be done like:

$winget_exe = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_*__8wekyb3d8bbwe\winget.exe"
if ($winget_exe.count -gt 1){
        $winget_exe = $winget_exe[-1].Path
}
if (!$winget_exe){Write-Error "Winget not installed"}Code language: PowerShell (powershell)

With that we're able to call winget from now on in our active session like:

& $winget_exeCode language: PHP (php)

Deploying Winget Apps with PSAppDeployToolkit

Now that we knwo hoow o call winget in the system context, we can create the package with PSAppDeployToolkit.
To du si add the follwing command to the respective sections in your Deploy-Application.ps1:

Installation routine

# Resolve winget.exe
$winget_exe = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_*__8wekyb3d8bbwe\winget.exe"
if ($winget_exe.count -gt 1){
        $winget_exe = $winget_exe[-1].Path
}
if (!$winget_exe){Write-Error "Winget not installed"}
# Installation via winget
& $winget_exe install "Notepad++.Notepad++" --silent --accept-source-agreements --accept-package-agreementsCode language: PHP (php)

Uninstallation routine

# Resolve winget.exe
$winget_exe = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_*__8wekyb3d8bbwe\winget.exe"
if ($winget_exe.count -gt 1){
        $winget_exe = $winget_exe[-1].Path
}
if (!$winget_exe){Write-Error "Winget not installed"}
# Installation via WinGet
& $winget_exe uninstall "Notepad++.Notepad++" --silentCode language: PHP (php)

Detailed Explanation

The previous sections provided a brief overview of the process of deploying Winget packages using PSAppDeployToolkit and Intune. For a more in-depth understanding, refer to my article on Home Page (tekkigurus.com).

This article delves into the technical aspects of the deployment process, covering topics such as:

  • Winget application types
  • Winget attributes
  • Winget as user vs system
  • Creating the PSAppDeployToolkit package
  • Options for Detection rules in Intune for winget
  • Creating an intunewin file using the Win32 Content Prep Tool
  • Deploying the app package to devices
  • Integrating PSAppDeployToolkit with Intune

By thoroughly understanding the detailed explanations provided in the original article, you can effectively implement and manage Winget package deployments using PSAppDeployToolkit and Intune.

In addition, here you find the package which I created as an example in this and the other article