Copy Registry values from HKLM to All HKCU


I am try to copy all values from ‘HKLM:\SOFTWARE\Source\App’ and copy into the HKCU for all users at ‘HKCU:\Software\Target\App’ using Invoke-HKCURegistrySettingsForAllUsers, the values for the source location are unique to each device, does anyone know how i can capture that information and then copy it to the target location? i’ve had little success with Get/Set-Registry Key so far via

 $registryValues = Get-RegistryKey -Key $sourceKeyPath


Invoke-HKCURegistrySettingsForAllUsers {
            foreach ($value in $registryValues) {
            Set-RegistryKey -Key $targetKeyPath -Name $value.Name -Value $value.Data -SID $UserProfile.SID -ContinueOnError $false

Many thanks

I have not run your code but if this works, what is the problem?

Think its because i want to target the entire key but the info captured by Get-RegistryKey cant be used in the foreach loop, so think i am going about it the wrong way

Nevermind, ive just use get-registrykey for all the values instead of the key and used a scriptblock into Invoke-HKCURegistrySettingsForAllUsers

Thank you for the help :slight_smile:

1 Like

Yes, always use a scriptblock with Invoke-HKCURegistrySettingsForAllUsers

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.