Invoke-HKCURegistrySettingsForAllUsers Question

Topics: Archive - General
Nov 25, 2014 at 4:58 PM
You seem to have updated this tool at the right time I was looking for something that can help me work with HKCU when deploying an install as SYSTEM.

My small scenario is that I need to remove a key from the HKCU before I install a piece of software.

If I understand this right, I first can invoke the Invoke-HKCURegistrySettingsForAllUsers command, then I should be able to use Remove-RegistryKey -Key command to remove the reg key I need.

I am OK with it being for all users, and was thinking of having this done in the pre-installation part.

I am thinking like this:

[scriptblock]$HKCURegistrySettings = {
Remove-RegistryKey -Key 'HKCU\Software' -Name 'Filetodelete' -SID $UserProfile.SID
}
Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings

My challenge, and it is what I am not sure about, is that this removal is a one time thing. Meaning it should only remove the reg key once during the install. If the product is uninstalled, and the script is run again it can remove the reg key again (although it should not exist)

Am I on the right path in understanding this, or am I way over my head.

My second this is to just create a dependency script in SCCM and have the reg remove as user and the install app as system.
Developer
Nov 25, 2014 at 6:27 PM
Yup you've got it right, the removal is just a one time thing.