0

I am writing a script that will be able to erase entries from the registry. The problem is that the endpoint in: HKCU:\Software\Microsoft\Windows\ CurrentVersion\Uninstall\{NUMBER} is not constant and changes each time the product is installed. I found a similar solution to the problem here, and changed the script to myself. But I still do not know how to delete exactly what is in the {NUMBER} folder .

At this time, the script can return only Publisher,DisplayName,DisplayVersion,UninstallString but resolves the problem so that the script returns the full path, or at least the name of the folder where these records are located? And would the best to be removed?

Here is my code:

$PATHS = @("HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\")
$SOFTWARE = "APPLICATION"

ForEach ($path in $PATHS) {
    $installed = Get-ChildItem -Path $path |
                 ForEach { Get-ItemProperty $_.PSPath } | 
                 Where-Object { $_.DisplayName -match $SOFTWARE } |
                 Select-Object -Property Publisher,DisplayName,DisplayVersion,UninstallString

    ForEach ($app in $installed) {
        Write-Output "$($app.DisplayName)"
    }
}
Claire Furney
  • 2,115
  • 3
  • 24
  • 36
Андрей Ка
  • 756
  • 4
  • 14
  • 33
  • Maybe this is the solution you are looking for: https://github.com/hsmalley/Powershell/blob/master/Get-InstalledApp.ps1 – f6a4 May 20 '18 at 10:00

1 Answers1

2

You didn't mention the PowerShell version, I assume it's PowerShell 5.1 running on Windows 10, wish it help:

Get-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" 

I think you can find whatever you want from the result:
PSChildName: the {number} you mentioned
InstallLocation: the folder where insatlled

As to display name, display version, publisher, etc, just pick the field.

Chenry Lee
  • 360
  • 2
  • 9