Find and display registry empty keys with Powershell
So you're looking for registry keys with no subkey and no property - except for the default value. Because both properties are provided when you use Get-ChildItem
you just have to filter for them:
Get-ChildItem -Path 'REGISTRY::HKEY_LOCAL_MACHINE', 'REGISTRY::HKEY_CURRENT_USER' -Recurse -ErrorAction SilentlyContinue |
Where-Object {
-not $_.SubKeyCount -and
-not $_.Property
} |
Select-object -Property PSPath
It is still a bad idea to remove keys from the registry without the need.