Search code examples
powershellscriptingregistry

Delete a registry entry based on the value using powershell


I need to delete a registry entry based on its value. For example, the key will reside in:

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

The DisplayName key will contain StackOverFlow.

The names of these registry keys are GUID, therefore random, so I can't just search for them, the only way is the one above.


Solution

  • $path = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
    
    gci $path |? {$_.GetValue('DisplayName') -match 'StackOverflow'} | del