Deleting Registry Key - Remove-Item

This topic contains 4 replies, has 2 voices, and was last updated by Profile photo of Andrew Andrew 1 year, 1 month ago.

  • Author
    Posts
  • #32848
    Profile photo of Andrew
    Andrew
    Participant

    Windows 7 64bit Powershell Version 4.0

    I am using

    if((Test-Path "HKLM:\SOFTWARE\Microsoft\SMS") -eq 'true'){
    Remove-Item "HKLM:\SOFTWARE\Microsoft\SMS" -Recurse -Force
    }

    and receive the following error:
    Remove-Item : Cannot delete a subkey tree because the subkey does not exist.

    the SMS reg key has one subkey Current user – the same type of test-path, remove-item has worked on several previous reg keys and subkeys – just fails on this one – has anyone seen this before?

  • #32849
    Profile photo of Mark Hammonds
    Mark Hammonds
    Participant

    Problem with sccm installing? I had a issue a while back all we needed to do is delete a sub key under mobile then restart the sms service then the new client would take. I will look for the script when I get to work if some one does not chime in first.

  • #32850
    Profile photo of Andrew
    Andrew
    Participant

    Hi Mark – yes, basically trying to wrap up about 10 steps in a script to clean out all the bits the SCCM client may leave behind after a failed 'uninstall'

  • #32851
    Profile photo of Mark Hammonds
    Mark Hammonds
    Participant

    What we did was delete the folder under c:\windows delete the reg keys then restart service. I will look when I get to work.

  • #33063
    Profile photo of Andrew
    Andrew
    Participant

    Think I have solved my issue – my Registry SubKey was continually in use, I have managed to get a working solution for my environment – which required me to convert my script into a PS Workflow (After I resume after a computer restart, my reg subkey can be deleted). I am impressed by workflows – awesome

    After I clear out all the SCCM folders, registry bits etc, I get a clean re-installation of the client by sending it from Configmanager – right click – Install

You must be logged in to reply to this topic.