This doesn’t work. Here’s my code: [scriptblock]$HKCURegistrySettings = {
Set-RegistryKey -Key “HKCU\Software\SoftPlan Systems Inc.\SoftPlan Workstation\16.3.4\C:$([char]0x2F)Program Files$([char]0x2F)SoftPlan2014\SoftPlan Folders” -Name ‘Projects’ -Value “S:$([char]0x2F)” -SID $UserProfile.SID
}
Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings
This creates a series of keys named C: \ Program Files \ SoftPlan2014 \ SoftPlan Folders </code> and then refuses to create the S:\ value because the Path doesn’t exist:
[03-18-2016 09:06:22.428] [Post-Installation] [Set-RegistryKey] :: Failed to set value [S:/] for registry key [Registry::HKEY_CURRENT_USER
Software\SoftPlan Systems Inc.\SoftPlan Workstation\16.3.4\C:/Program Files/SoftPlan2014\SoftPlan Folders] [Projects].
Error Record:
Message : Cannot find path ‘HKEY_CURRENT_USER\Software\SoftPlan Systems Inc.\SoftPlan Workstation\16.3.4\C:/Program
Files/SoftPlan2014\SoftPlan Folders’ because it does not exist.
InnerException :
FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.NewItemPropertyCommand
ScriptStackTrace : at Set-RegistryKey<Process>, \5000m45\packagesource$\Software_8\Softplan_Educational_Workstation_2014\AppDeployTo
olkit\AppDeployToolkitMain.ps1: line 3737
at <ScriptBlock>, <No file>: line 1
Now, this wysisyg is not very “character friendly” but your string would look something like this (if all characters are allowed in here):
‘HKCU\Software\X\https://google.com`/’
Normally solves my scripts involving spooky characters.
Comes out as two REG_SZ strings with both slashes backslashes formatted correctly. The 2nd one obviously has a messed up value, but proved to me that came out as expected in the registry.
Might be something in the Function Set-RegistryKey that messes things up. It does go beyond the normal PS cmdlets for adding items in the registry, so might be.
Again, please mind the automatic formatting on the site. I did put a ` in front of every special character and surrounded the entire value string with quotation marks.
I’m having problems with the key name, not the value of a property. I’ve created a bug report on the tracker for it that has more detail about what I’ve tried.
I can’t seem to create a key with forward slashes in it or write to an existing key with the same. Values seem to work out fine.