/WinGet-Wrapper

PowerShell Scripts to deploy and bulk import WinGet packages to InTune including all metadata.

Primary LanguagePowerShellGNU General Public License v3.0GPL-3.0

WinGet-Wrapper

PowerShell Scripts to deploy and bulk import WinGet packages to InTune including metadata.
Automatically detect latest version using dynamic detection script.
Detection script checks local installed version against latest winget available version or a defined fixed target version.
Bulk import WinGet packages to InTune including WinGet package metadata using WinGet-WrapperImportFromCSV.ps1

  • Dynamically finds the WinGet directory to be used under System Context.
  • Kill selected process before WinGet command
  • Allows running pre and post script before installation
  • Detection script that dynamically finds latest package available trough WinGet
  • Requirement script to allow creating packages for update purposes only
  • Logs to $env:ProgramData\WinGet-WrapperLogs (Usually C:\ProgramData\WinGet-WrapperLogs)
  • Dynamically detect if running in user or system context
  • Performs automatic cleanup of log files older than 60 days.
  • Directly import and deploy WinGet packages to InTune including WinGet package metadata

Background / Why?

WinGet have a few limitations in terms of automation and is not integrated with common endpoints management products.
System Context is not possible by using "winget" as the .exe location must be found and this location is not static due to versioning in the directory name.

Requirements

Newer Windows OS build that includes the WinGet natively in the OS
Windows 10 20H2 or newer should be enough
Powershell 5.1
WinGet-WrapperImportFromCSV.ps1 automatically installs required module "IntuneWin32App" (github.com/MSEndpointMgr/IntuneWin32App)

WinGet-Wrapper.ps1

image

Usage:

Powershell.exe -NoLogo -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File WinGet-Wrapper.ps1 -PackageName "PackageName for log file" -StopProcess "kill process using Stop-Process (do not add .exe)" -PreScript "somefile.ps1" -PostScript "somefile.ps1" -ArgumentList "Arguments Passed to WinGet.exe"

WinGet-WrapperDetection.ps1

Matches locally installed version with newest available version using WinGet or specified version using $TargetVersion
Can be setup to accept newer installed version locally $AcceptNewerVersion

image

WinGet-WrapperRequirements.ps1

Checks if application is detected locally. If not detected will not attempt update/install
To be used when only wanting to update if application is already installed. (Update Only)

image

Outputs either "Installed" or "Not Installed"

image

WinGet-WrapperImportFromCSV.ps1

Imports packages from WinGet to InTune (incuding available WinGet package metadata)
Package content is stored under Packages\Package.ID-Context-UpdateOnly-UserName-yyyy-mm-dd-hhssmm
Create deployment using csv columns: InstallIntent, Notification, GroupID

image

Usage: Import from CSV (InTune)

Open the sample CSV file WinGet-WrapperImportFromCSV.csv and add any WinGet Package IDs to import (Case Sensitive)

Usage:

WinGet-WrapperImportFromCSV.ps1 -TenantID company.onmicrosoft.com -csvFile WinGet-WrapperImportFromCSV.csv -SkipConfirmation

Process:

image

Results:

image

Columns:

  • PackageID = Exact PackageID (Required)
  • Context = Which context the Win32App is run under (Machine or User) (Required)
  • AcceptNewerVersion = Allows newer installed version locally than specified (Set to 0 or 1)(Required)
  • UpdateOnly = Update package only. Application will only update if application is already installed (Set to 0 or 1)(Required)
  • TargetVersion = Specfic version of the application. If not set, the package will always be the latest version
  • StopProcessInstall = Kill a specific process (Stop-process) before installation (.exe should not be defined)
  • StopProcessUninstall = Kill a specific process (Stop-process) before uninstallation (.exe should not be defined)
  • PreScriptInstall = Run powershell script before installation
  • PostScript = Run powershell script after installation
  • PreScriptUninstall = Run powershell script before uninstallation
  • PostScriptUninstall = Run powershell script after uninstallation
  • CustomArgumentListInstall = Arguments passsed to WinGet (default: install --exact --id PackageID --silent --accept-package-agreements --accept-source-agreements --scope Context
  • CustomArgumentListUninstall = Arguments passsed to WinGet (default: uninstall --exact --id PackageID --silent --accept-source-agreements --scope Context
  • InstallIntent = Available or Required deployment
  • Notification = Notification level on deployment - Valid values: showAll, showReboot, hideAll
  • GroupID = InTune GroupID to deploy package to

Usage: Manual Import (InTune)

Application Installation

In InTune create an Windows app (Win32) and upload WinGet-Wrapper.InTuneWin as the package file.

Install: Powershell.exe -NoLogo -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File WinGet-Wrapper.ps1 -PackageName "VideoLAN.VLC" -StopProcess "VLC" -ArgumentList "install --exact --id VideoLAN.VLC --silent --accept-package-agreements --accept-source-agreements --scope machine"

Uninstall: Powershell.exe -NoLogo -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File WinGet-Wrapper.ps1 -PackageName "VideoLAN.VLC" -StopProcess "VLC" -ArgumentList "Uninstall --exact --id VideoLAN.VLC --silent --accept-source-agreements --scope machine"

Change the $id variable to match the package id in the detection script and upload it ($id = "VideoLAN.VLC")
If specific version is required change the $TargetVersion (Ex. $TargetVersion = "1.0.0.0")

image

Application Update Only

For creating application that will only update/install if application is already installed
Perform the same steps as in "Application Installation".
Setup Requirement rule script with return string value of "Installed"

image

image