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)"
    }
}
1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

@Andrej Thanks for feedback.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.