Deleting Registry Key - Remove-Item

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?

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.

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’

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.

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