Add all existing user registry values with their user paths

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

Look into Active Setup to do per-user changes.

BTW: the reason you did not get a prompt reply is because you should have posted your question here: General Discussion - PSAppDeployToolkit Community

Hello !

Invoke-HKCURegistrySettingsForAllUsers sets $UserProfile with Get-UserProfiles, so you can use $UserProfile.ProfilePath directly inside your $HKCURegistrySettings block.

Working example :

$HKCURegistrySettings = {
  Set-RegistryKey -Key 'HKCU\Software\ABC\XYZ' -Name AAA -Value ('{0}\Documents\AAA' -f $UserProfile.ProfilePath) -Type String -SID $UserProfile.SID
}
Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings