For instance, I have the following  key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ACME

Under that I  have
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ACME\.doc
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ACME\.xls
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ACME\.vbs
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ACME\.html
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ACME\CLSID

The CLSID has  subkeys. The objective is to delete all the subkeys under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ACME \ACME\
except
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ACME\CLSID and its subkeys. I am
trying to be as clear as possible.

First to see what would be done with the command, run this:Get-ChildItem HKLM:\SOFTWARE\Microsoft\ACME | Where-Object
{$_.PSChildName -ne ‘CLSID’} | Remove-Item -Force -WhatIf

That will tell  you what would happen if you were to run it without -WhatIf. If the results look
like what you want, do this:

Get-ChildItem HKLM:\SOFTWARE\Microsoft\ACME  | Where-Object {$_.PSChildName -ne ‘CLSID’} | Remove-Item -Force

That’s all there is to it!