Initialize-Winget

1.4

This script ensures WinGet is properly installed and functional. It will:
1. Verify WinGet can find packages using the 'Microsoft.WinGet.Client' module.
2. Attempt to repair WinGet if package search fails.
3. Install WinGet and its dependencies if repair fails.
4. Locate and verify the winget.exe path.

The script also ensures that necessary helper module 'Microsoft.W
This script ensures WinGet is properly installed and functional. It will:
1. Verify WinGet can find packages using the 'Microsoft.WinGet.Client' module.
2. Attempt to repair WinGet if package search fails.
3. Install WinGet and its dependencies if repair fails.
4. Locate and verify the winget.exe path.

The script also ensures that necessary helper module 'Microsoft.WinGet.Client' is installed and imported.

Show more

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Script -Name Initialize-Winget

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Package Details

Author(s)

  • Jonathan Pitre

Tags

Winget Intune Autopilot PowerShell Automation

Functions

Get-WinGetPath

Dependencies

This script has no dependencies.

Release Notes

1.4 - 2025-07-05
- Changed default log file name from 'WinGet_Initialization.log' to 'Initialize-Winget.log' for clarity.
- Removed unnecessary parameters from Install-PSResource and Update-PSResource commands to streamline the installation process.
- Created [Pull Request #67](https://github.com/asheroto/winget-install/pull/67) to fix winget-install error with SYSTEM context and other issues
- Added version checking and update logic for the Microsoft.WinGet.Client module.
- Improved error handling for locating winget.exe and added fallback mechanisms.
- Optimized output encoding reset and transcript handling for better script execution flow.
- Enhanced module management efficiency by leveraging the Microsoft.PowerShell.PSResourceGet module's optimized cmdlets.
- Fixed an error with the transcript file not being created on a fresh reboot.
1.3 - 2025-06-02
- Fixed try/catch block
- Improved logging and error handling
- Improved winget.exe path detection
1.2 - 2025-05-30
- Removed dependency on PSAppDeployToolkit.WinGet
- Fixed error "Find-ADTWinGetPackage -Id Microsoft.AppInstaller -Count 1 -Source winget"
- Improved logging and error handling
1.1 - 2025-05-30
- Fixed "Failed to execute Winget command: Cannot validate argument on parameter 'Id'"
- Improved logging and error handling
1.0 - 2025-05-28
- Initial release

FileList

Version History

Version Downloads Last updated
1.4 (current version) 88 7/7/2025
1.3 269 6/2/2025
1.2 6 5/30/2025
1.1 6 5/30/2025
1.0 7 5/29/2025