Remove-registrykey question

Topics: Archive - General
Mar 2, 2015 at 5:33 PM
I am working on a app that does not always cleanly remove reg keys. I started playing with remove-registrykey -key.... -name... etc. Its really, really close to remove-item -path hklm....

the question is this;

Can I have a line like so and will it work?

Remove-registryKey -Key "HKCR:\CLSID{F2EFC293-6D96-43A5-B043-BC80F000AD7A}" -ErrorAction SilentlyContinue

The doc talks about continueonerror but not how to properly use it. Also I looked at the appdeploy main ps1 file and see that there are references to recurse in it as well. Will recurse be used always or is that another item I need to add?
Like so;
Remove-registryKey -Key "HKCR:\CLSID{F2EFC293-6D96-43A5-B043-BC80F000AD7A}" -ErrorAction SilentlyContinue -recurse

thanks in advance.

I am using 3.2.0 and powershell 4.0 with various OS versions via CM12 r2 CU3.
Developer
Mar 12, 2015 at 2:51 AM
ContinueOnError has a default value to $true so it will always continue without you specifying this setting. You can set it to false to throw a terminating error. Also, yes, you have to specify -Recurse if you want to use that functionality.