Error on trying to search and delete Register SubKeyTree

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Don Jones Don Jones 4 months, 3 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #38701
    Profile photo of pulgalipe

    I'm trying to remove some keys from register based on an array of paths which I would search for a few keywords and want to delete the "Tree" where the subkey was found.

    But after trying to figure it out, the script down below is not working.

    $computerName = $env:computername
    $Register = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computerName)
    foreach($chave in $KeyToRemove){
    $RegisterKey = $Register.OpenSubkey($chave)
    $NomeSubChaves = $RegisterKey.GetSubKeyNames() | ForEach-Object
    $Value = $NomeSubChaves.GetValue($_)

    $RegisterKey.GetValueNames() | ForEach-Object
    $Value = $RegisterKey.GetValue($_)
    "Value name: {0} had data: {1}" -f $_,$Value


    Can anybody help me with this issue?


    Profile photo of Don Jones
    Don Jones

    Can you be more specific than "not working?"

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.