Skip to content

bfcns/wingetlist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Also can be downloaded from: https://www.powershellgallery.com/packages/Get-WingetList

Get-WingetList PowerShell Script

Overview

Get-WingetList.ps1 is a PowerShell script designed to list and manage installed packages using the Windows Package Manager (winget). It provides detailed information about installed packages from different sources (winget, msstore, and packages with no source), including their names, IDs, versions, and optionally VirusTotal links for winget packages. The script supports exporting reports in Markdown and HTML formats and can update a SHA256 cache for VirusTotal links.

alt text

This script is useful for system administrators, IT professionals, and users who want to audit installed software, check for updates, or generate reports about their system's package inventory.

Features

  • List Installed Packages: Displays all installed packages, grouped by source (winget, msstore, and no source) and update status (updatable or not).
  • VirusTotal Integration: Optionally retrieves VirusTotal links for winget packages based on their SHA256 hashes, with caching to improve performance.
  • Export Options: Generates reports in Markdown (WingetListReport.md) or HTML (WingetListReport.html) formats for easy sharing or documentation.
  • Updateable Package Detection: Identifies packages with available updates and displays their current and available versions.
  • SHA256 Cache Management: Maintains a local JSON cache (wingetlist-sha-cache.json) to store SHA256 hashes and avoid redundant queries.
  • Command-Line Flexibility: Supports parameters for filtering, updating VirusTotal links, and exporting reports.

Prerequisites

  • PowerShell Core 7.0 or higher: The script requires PowerShell Core (#Requires -PSEdition Core -Version 7.0).

  • Windows Package Manager (winget): The winget.exe command-line tool must be installed. It is included with Windows 10 version 1809 or later or can be installed via the Microsoft Store.

  • Microsoft.WinGet.Client PowerShell Module: The Get-WinGetPackage cmdlet is required. Install it from the PowerShell Gallery using:

    Install-Module -Name Microsoft.WinGet.Client -RequiredVersion 1.10.340
  • Windows Operating System: The script is designed for Windows environments where winget is supported.

Installation

  1. Download the Script:

    • Clone this repository or download the Get-WingetList.ps1 file:

      git clone https://github.com/bfcns/Get-WingetList.git
  2. Place the Script:

    • Save Get-WingetList.ps1 in a directory of your choice (e.g., C:\Scripts).
  3. Install Dependencies:

    • Ensure winget.exe is available. Verify by running:

      winget --version
    • Install the Microsoft.WinGet.Client module if not already installed:

      Install-Module -Name Microsoft.WinGet.Client -RequiredVersion 1.10.340

Usage

Run the script in PowerShell Core with the desired parameters. Below are the available parameters and examples.

Parameters

Parameter Alias Type Description
-Name String Filter packages by name (optional).
-IncludeVirusTotalLink -i Switch Include VirusTotal links for winget packages in the output.
-UpdateVirusTotalLink -u Switch Update the SHA256 cache and fetch VirusTotal links for winget packages.
-ExportMarkdown -m Switch Export the package list to a Markdown file (WingetListReport.md).
-ExportHtml -h Switch Export the package list to an HTML file (WingetListReport.html).

Examples

  1. List All Installed Packages: Display all installed packages grouped by source and update status:

    .\Get-WingetList.ps1
  2. Include VirusTotal Links: Display packages with VirusTotal links for winget packages (uses cached SHA256 hashes):

    .\Get-WingetList.ps1 -IncludeVirusTotalLink
  3. Update SHA256 Cache: Fetch and update SHA256 hashes for winget packages and save to wingetlist-sha-cache.json:

    .\Get-WingetList.ps1 -UpdateVirusTotalLink
  4. Export to Markdown: Generate a Markdown report of all packages:

    .\Get-WingetList.ps1 -ExportMarkdown

    Output is saved to WingetListReport.md.

  5. Export to HTML: Generate an HTML report of all packages:

    .\Get-WingetList.ps1 -ExportHtml

    Output is saved to WingetListReport.html.

  6. Combine Options: List packages, include VirusTotal links, and export to both Markdown and HTML:

    .\Get-WingetList.ps1 -IncludeVirusTotalLink -ExportMarkdown -ExportHtml

Output

Console Output

The script groups packages into six categories and displays them in the console:

  • Winget Updateable Installed Packages: winget packages with available updates.
  • Winget Installed Packages: winget packages that are up-to-date.
  • Store Updateable Installed Packages: Microsoft Store (msstore) packages with available updates.
  • Store Installed Packages: msstore packages that are up-to-date.
  • No Source Updateable Installed Packages: Packages with no source that have updates.
  • No Source Installed Packages: Packages with no source that are up-to-date.

Each group is displayed as a table with columns for Name, Id, Version, and optionally New Version (for updateable packages) and VirusTotalLink (for winget packages when -IncludeVirusTotalLink or -UpdateVirusTotalLink is used).

Markdown Output (WingetListReport.md)

When -ExportMarkdown is specified, the script generates a Markdown file with tables for each source:

  • Winget Packages: Includes Name, Version, Id, and VirusTotalLink (if enabled).
  • MSStore Packages: Includes Name, Version, and Id.
  • No Source Packages: Includes Name, Version, and Id.

Example Markdown output:

## Winget Packages

| Name        | Version | Id          | VirusTotalLink                                |
| ----------- | ------- | ----------- | --------------------------------------------- |
| Example App | 1.0.0   | Example.App | https://www.virustotal.com/gui/file/abc123... |

## MSStore Packages

| Name      | Version | Id           |
| --------- | ------- | ------------ |
| Store App | 1.2.3   | 9NBLGGH4NNS1 |

## No Source Packages

| Name        | Version | Id          |
| ----------- | ------- | ----------- |
| Unknown App | 1.0     | Unknown.App |

HTML Output (WingetListReport.html)

When -ExportHtml is specified, the script generates an HTML file with tables for each source, styled with basic HTML formatting. VirusTotal links are rendered as clickable hyperlinks.

Example HTML output:

<h2>Winget Packages</h2>
<table border="1">
  <tr>
    <th>Name</th>
    <th>Version</th>
    <th>Id</th>
    <th>VirusTotalLink</th>
  </tr>
  <tr>
    <td>Example App</td>
    <td>1.0.0</td>
    <td>Example.App</td>
    <td>
      <a href="https://www.virustotal.com/gui/file/abc123...">VirusTotal</a>
    </td>
  </tr>
</table>
<h2>MSStore Packages</h2>
<table border="1">
  <tr>
    <th>Name</th>
    <th>Version</th>
    <th>Id</th>
  </tr>
  <tr>
    <td>Store App</td>
    <td>1.2.3</td>
    <td>9NBLGGH4NNS1</td>
  </tr>
</table>
<h2>No Source Packages</h2>
<table border="1">
  <tr>
    <th>Name</th>
    <th>Version</th>
    <th>Id</th>
  </tr>
  <tr>
    <td>Unknown App</td>
    <td>1.0</td>
    <td>Unknown.App</td>
  </tr>
</table>

SHA256 Cache (wingetlist-sha-cache.json)

When -UpdateVirusTotalLink is used, the script updates a JSON file (wingetlist-sha-cache.json) with SHA256 hashes for winget packages. The cache format is:

{
  "Example.App": {
    "Version": "1.0.0",
    "SHA": "abc123..."
  }
}

Notes

  • SHA256 Cache: The script stores SHA256 hashes in wingetlist-sha-cache.json to avoid redundant winget show commands. Use -UpdateVirusTotalLink to refresh the cache for new or updated packages.
  • VirusTotal Links: Links are only generated for winget packages and require a valid SHA256 hash. If a hash is missing, the script prompts to run with -UpdateVirusTotalLink.
  • Error Handling: The script checks for the presence of winget.exe and Get-WinGetPackage. If either is missing, it provides instructions and exits.
  • Performance: The script processes packages in parallel when updating the SHA256 cache to improve performance for large package lists.
  • Encoding: Output files (WingetListReport.md and WingetListReport.html) are saved in UTF-8 encoding.

Tip: You can add an alias to your powershell $Profile file as:

Set-Alias -Name wgl -Value Get-WingetList

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature/your-feature).
  3. Commit your changes (git commit -m "Add your feature").
  4. Push to the branch (git push origin feature/your-feature).
  5. Open a pull request.

Please ensure your code follows PowerShell best practices and includes appropriate comments.

Issues

If you encounter bugs or have feature requests, please open an issue on the GitHub Issues page. Provide detailed information, including:

  • PowerShell version
  • Operating system
  • Steps to reproduce
  • Expected behavior
  • Actual behavior

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

  • Built with PowerShell Core and the Microsoft.WinGet.Client module.
  • Inspired by the need to audit and manage software installations on Windows systems.
  • Thanks to the open-source community for providing tools like winget.

About

The Get-WingetList script enumerates installed packages using the WinGet PowerShell client and displays them grouped by source (winget, msstore, or none) and update availability. It can optionally export the package list to Markdown or HTML reports, and fetch VirusTotal links for winget packages by retrieving their installer SHA256 hashes.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors