Retrieve Uninstall Strings for Installed Software
PowerShell Script to Find Uninstall Strings for Installed Software (Excluding Microsoft Store Apps)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Define the registry paths
$paths = @(
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall",
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall",
"HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
)
# Create an array to store the results
$uninstallInfo = @()
# Loop through each registry path
foreach ($path in $paths) {
# Get all subkeys in the path
Get-ChildItem -Path $path -ErrorAction SilentlyContinue | ForEach-Object {
$app = Get-ItemProperty -Path $_.PsPath -ErrorAction SilentlyContinue
# Collect app details
[PSCustomObject]@{
Name = $app.DisplayName
Publisher = $app.Publisher
Version = $app.DisplayVersion
UninstallString = $app.UninstallString
}
} | Where-Object { $_.Name -ne $null } | ForEach-Object {
$uninstallInfo += $_
}
}
# Create folder if it does not exist
$folderPath = "C:\shit"
if (-Not (Test-Path -Path $folderPath)) {
New-Item -Path $folderPath -ItemType Directory
}
# Export to a CSV file without truncation
$filePath = "$folderPath\UninstallStrings_Full.csv"
$uninstallInfo | Export-Csv -Path $filePath -NoTypeInformation -Encoding UTF8
# Export to a text file with detailed formatting
#$textFilePath = "$folderPath\UninstallStrings_Full.txt"
#$uninstallInfo | ForEach-Object {
# "Name: $_.Name`nPublisher: $_.Publisher`nVersion: $_.Version`nUninstall String: $_.UninstallString`n`n"
#} | Out-File -FilePath $textFilePath -Encoding UTF8
Write-Host "Exported uninstall details to $filePath" # and $textFilePath"
pause
This post is licensed under CC BY 4.0 by the author.