How to remove Registry Keys with wildcards

PowerShell's registry provider allows you to work with registry keys in a manner almost identical to working with files, including using wildcards in paths:

PS C:\>>dir hklm:\so*\mi*


    Hive: HKEY_LOCAL_MACHINE\SOFTWARE


Name                           Property
----                           --------
Microsoft

PowerShell's wildcards include the familiar * and ?, as well as [<list or range>]:

PS C:\>>gci 'HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\[1,3][5-8]'


    Hive: HKEY_CURRENT_USER\SOFTWARE\Classes\Local
    Settings\Software\Microsoft\Windows\Shell\Bags


Name                           Property
----                           --------
15
16
17
18
35
36
37
38

So, the OP would use:

del 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{CD95F661-A5C4-44F5-A6AA-ECDD91C240*' -Recurse

or more precisely (for GUIDs):

ri 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{CD95F661-A5C4-44F5-A6AA-ECDD91C240??}' -Recurse
  • Without the -Recurse parameter, keys with subkeys will display a confirmation message.
  • dir = gci = Get-ChildItem
  • del = ri = Remove-Item