I am trying to get this script to find all registries containing "e:\UC" in either its data or name. Most of the matches are not going to be an exact match and "e:\UC" will be in the beginning or middle of the Data or Name.
This is the script I cannot get to work with what I am trying to do. I believe that it is checking the data but not the name.
$RE = 'e:\UC'
$Key = 'HKLM'
Get-ChildItem $Key -Rec -EA SilentlyContinue | ForEach-Object {
$CurrentKey = (Get-ItemProperty -Path $_.PSPath)
if ($CurrentKey -match $RE) {
$CurrentKey | Remove-Item -Force -Whatif
}
}