Skip to content

winget_setup.ps1

Corey Watson edited this page Dec 4, 2025 · 1 revision

winget_setup.ps1

Installs winget (Windows Package Manager) on Windows systems using the most reliable installation method.

Overview

Installs winget (Windows Package Manager) on Windows systems using the most reliable installation method. Optimized for RMM environments running under SYSTEM context. Uses manual AppX installation method which is more reliable than the Repair-WinGetPackageManager approach. Handles all OS versions including Windows 10, 11, and Server 2019+.

Purpose

Installs winget (Windows Package Manager) on Windows systems using the most reliable installation method. Optimized for RMM environments running under SYSTEM context. Uses manual AppX installation method which is more reliable than the Repair-WinGetPackageManager approach. Handles all OS versions including Windows 10, 11, and Server 2019+.

Prerequisites

  • Administrator or SYSTEM privileges
  • Windows 10 1809+ or Windows Server 2019+
  • Internet connectivity to GitHub
  • PowerShell 5.1 or higher

Configuration

Required Inputs

  • $forceReinstall - Reinstall even if winget already exists (boolean)
  • $downloadTimeout - Timeout for file downloads in seconds (integer)
  • $skipServerCore - Skip installation on Server Core (boolean)

Data Sources & Priority

  1. Hardcoded script configuration (timeout, force reinstall)
  2. GitHub API (microsoft/winget-cli releases)
  3. System environment (OS version, architecture)

Settings

  • Uses alternate/manual AppX installation method (most reliable)
  • Automatically detects SYSTEM context and adjusts behavior
  • Installs for all users when possible
  • Configures PATH environment variable automatically
  • 120 second download timeout per file

Behavior

  1. Validates configuration inputs
  2. Checks OS compatibility and admin privileges
  3. Detects if running as SYSTEM account
  4. Checks if winget is already installed (skips if present unless forced)
  5. Downloads winget dependencies from GitHub
  6. Downloads winget AppX package from GitHub
  7. Installs dependencies (VCLibs, UI.Xaml)
  8. Installs winget AppX package
  9. Configures PATH environment variable
  10. Registers winget application
  11. Verifies installation success
  12. Cleans up temporary files

Security Notes

  • No secrets or credentials required
  • Downloads only from official Microsoft GitHub repository
  • All temporary files are cleaned up after installation
  • No sensitive information logged to console

Exit Codes

  • 0 = Success - winget installed and verified
  • 1 = Failure - installation failed or system incompatible

Example Output

[ INPUT VALIDATION ]
--------------------------------------------------------------
Configuration validated successfully
Force Reinstall : No
Download Timeout: 120 seconds

[ SYSTEM CHECK ]
--------------------------------------------------------------
OS Version      : Windows 10 22H2
Architecture    : x64
Admin Rights    : Yes
Running Context : SYSTEM
Winget Status   : Not installed

[ DOWNLOAD DEPENDENCIES ]
--------------------------------------------------------------
Fetching latest release information...
Latest Version  : v1.7.10861
Downloading dependencies package...
Downloaded      : 15.2 MB
Extracting dependencies...
Extracted       : VCLibs.140.00.UWPDesktop
Extracted       : UI.Xaml.2.8

[ DOWNLOAD WINGET ]
--------------------------------------------------------------
Downloading winget package...
Downloaded      : 45.8 MB
Package verified

[ INSTALL DEPENDENCIES ]
--------------------------------------------------------------
Installing VCLibs.140.00.UWPDesktop...
Installed successfully
Installing UI.Xaml.2.8...
Installed successfully

[ INSTALL WINGET ]
--------------------------------------------------------------
Installing winget AppX package...
Installation successful
Configuring PATH environment variable...
PATH configured
Registering winget...
Registration complete

[ VERIFICATION ]
--------------------------------------------------------------
Testing winget command...
Winget Version  : v1.7.10861
Installation    : Verified

[ CLEANUP ]
--------------------------------------------------------------
Removing temporary files...
Cleanup complete

[ FINAL STATUS ]
--------------------------------------------------------------
Status          : Success
Winget          : Installed and working

[ SCRIPT COMPLETED ]
--------------------------------------------------------------

Version History

  • 2025-01-31 v1.0.0 - Initial release - reliable winget installation for RMM

Links

Clone this wiki locally