0

I wanted to loop through registry entries using powershell and uninstall certain MSIs.

I found the answer in this post very simillar to my requirement. However I have a slight different requirement. (I dont want to use UnInstall String)

I get a list of all registries in 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' and I want to use the NAME (i.e. the productcode) of the registry itself.

My Question: How to get the name of the registry.

2 Answers 2

2

You need to use Get-ChildItem.

For example, this gives the Name of the key under Uninstall key.

Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | Select PSChildName

Update based on the comment:

Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | Where-Object {
 $_.PSChildName -Eq '{D2B9C003-A3CD-44A0-9DE5-52FE986C03E5}'} | Select PSChildName
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! How can include a filter which gets me only those entries whose DisplayName contains "ABC"?
Please check the updated answer. Is that what you are expecting?
1

You shouldn't really be trolling the registry. The correct way to do this for MSI-based installs is to use MsiEnumProducts to find all the installed MSI products, use the returned product code to get info about their names and versions (MsiGetProductInfo) to see if you want to uninstall them, and then use MsiConfigureProduct and set them to installstate_absent. If you dig around you may find some p/invoke interop code to do this from managed code, that would get you into PowerShell.

Comments

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.