Scripts

Script

Export installed programs

Write uninstall registry entries to a CSV (Windows).

intermediate system inventory

Reads the Uninstall keys for the current view of the registry. 32-bit vs 64-bit and per-user installs can hide entries. This is a starting inventory, not a perfect software CMDB.

.\export-installed-programs.ps1 -OutputPath .\programs.csv

Parameters

Name Type Required Description
-OutputPath string Yes CSV file to write.

Source

export-installed-programs.ps1
Download
<#
.SYNOPSIS
    Export installed programs from Uninstall registry keys to CSV.

.PARAMETER OutputPath
    CSV file to write.

.EXAMPLE
    .\export-installed-programs.ps1 -OutputPath .\programs.csv
#>
[CmdletBinding(SupportsShouldProcess)]
param(
    [Parameter(Mandatory)]
    [string]$OutputPath
)

$ErrorActionPreference = 'Stop'

# UTF-8 with a BOM so Excel shows non-ASCII names correctly on 5.1 and 7.
$csvEncoding = if ($PSVersionTable.PSVersion.Major -ge 6) { 'utf8BOM' } else { 'UTF8' }

$keys = @(
    'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
    'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*',
    'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*'
)

$rows = foreach ($key in $keys) {
    Get-ItemProperty -Path $key -ErrorAction SilentlyContinue |
        Where-Object { $_.DisplayName } |
        Select-Object DisplayName, DisplayVersion, Publisher, InstallDate
}

$unique = $rows | Sort-Object DisplayName, DisplayVersion -Unique

if ($PSCmdlet.ShouldProcess($OutputPath, 'Write installed programs CSV')) {
    $unique | Export-Csv -LiteralPath $OutputPath -NoTypeInformation -Encoding $csvEncoding
    Write-Output $OutputPath
}

Downloaded it? Windows blocks scripts from the internet until you unblock them: Unblock-File -Path .\export-installed-programs.ps1. See Run a script.