Set-RegistryKey "HKEY_CURRENT_USER\~ -SID $Profile.SID fails on Main's Test-Path

We have found that using Test-Path in our environment fails intermitently, so much as we are directed to not use Test-Path in any of our scripts.
But AppDeployToolkitMain.ps1 is loaded with this cmdlet. I have managed to avoid too many AppDeployToolkitMain.ps1 edits but
when using Set-RegistryKey with Get-UserProfiles there is not an easy way around. PSADT makes it too easy by avoiding scripting all users of a computer.

This simple PSADT script fails:
$Profiles = Get-UserProfiles -ExcludeDefaultUser $true -ExcludeNTAccount @(name,name)
ForEach ($Profile in $Profiles) {
Set-RegistryKey -Key ‘HKEY_CURRENT_USER\Software\ABCompany’ -Name ‘Appearance’ -SID $Profile.SID -Type ‘DWord’ -Value ‘128’
}
ERROR:
Message : The parameter is incorrect.

InnerException :
~
PositionMessage : At D:_Projects\ABCompany\AppDeployToolkit\AppDeployToolkitMain.ps1:6926 char:32
+ … $null = New-Item -Path $key -ItemType ‘Registry’ -Force -ErrorAct …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Any ideas on how to get around PSADT Test-Path’s failure without re-writing AppDeployToolkitMain.ps1?
Test-Path cannot be used with Try/catch as it returns true/false and needs extra scripting to fail properly (might as well use Get-Item,Get-ItemProperty, Resolve-Path, etc.)

This could be down to your choice of quote marks, try using either straight double quotes: ""
or straight single quotes: '' around your settings
It looks like you might have either used non ANSI characters or non-straight single quotes: ``

So with your code it should look like this:

$Profiles = Get-UserProfiles -ExcludeDefaultUser $true -ExcludeNTAccount @(name,name)
ForEach ($Profile in $Profiles) {
    Set-RegistryKey -Key 'HKEY_CURRENT_USER\Software\ABCompany' -Name 'Appearance' -SID $Profile.SID -Type 'DWord' -Value '128'
}

N.B. The ` is a reserved character in PowerShell and is often used to “escape” (ignore) the next character.
This can be helpful if you want to output other reserved characters such as $
e.g.

$OutputText = "This is some random text"
Write-Output "`$OutputText" #Outputs Variable name
Write-Output "$OutputText" #Outputs Variable content
Write-Output "`$OutputText contains: $OutputText" # Outputs both Variable name and Content