I have a new use case, there user keys are to be added, the value section is to contain the profile path of the respective user.
I have tried the following, but I have not achieved any result.
$ProfilePaths = Get-UserProfiles | Select-Object -ExpandProperty ‘ProfilePath’
$HKCURegistrySettings = {Set-RegistryKey -Key ‘HKCU\Software\ABC\XYZ’ -Name ‘AAA’ -Value “$ProfilePaths/Documents/AAA” -Type String -SID $UserProfile.SID
Set-RegistryKey -Key ‘HKCU\Software\ABC\XYZ’ -Name ‘BBB’ -Value “$Profile/Documents/BBB” -Type String -SID $UserProfile.SID
Set-RegistryKey -Key ‘HKCU\Software\ABC\XYZ’ -Name ‘CCC’ -Value “$UserProfile/Documents/CCC” -Type String -SID $UserProfile.SID
Set-RegistryKey -Key ‘HKCU\Software\ABC\XYZ’ -Name ‘DDD’ -Value “C:\Users$EnvUserName/Documents/DDD” -Type String -SID $UserProfile.SID}
Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings