I have a very simple powershell script that I setup to add a registry value for a chrome management token.
Script:
Set-ItemProperty -Path Registry::"HKLM\SOFTWARE\Policies\Google\Chrome" -Name "CloudManagementEnrollmentToken" -Value "----" -Force
When I run this script manually on system it works fine.
When Intune runs this on a system without the key already present it generates the following error telling me the path is not there instead of creating the entry:
"error from script =Set-ItemProperty : Cannot find path 'HKLM\SOFTWARE\Policies\Google\Chrome' because it does not exist.
At C:\Program Files (x86)\Microsoft Intune Management
Extension\Policies\Scripts\00000000-0000-0000-0000-000000000000_c4c07194-db96-4dfa-aa15-1c705a740608.ps1:2 char:1
+ Set-ItemProperty -Path Registry::"HKLM\SOFTWARE\Policies\Google\Chrom ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKLM\SOFTWARE\Policies\Google\Chrome:String) [Set-ItemProperty], ItemNo
tFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetItemPropertyCommand"
However on a system that already has this key in place Intune successfully runs the script:
"cmd line for running powershell is -executionPolicy bypass -file "C:\Program Files (x86)\Microsoft Intune Management Extension\Policies\Scripts\00000000-0000-0000-0000-000000000000_c4c07194-db96-4dfa-aa15-1c705a740608.ps1"
Powershell script is successfully executed."
I have even tried the following scripts to force it to check for the presence and then create the value if it is not present, but they fail when running them manually so I have not attempted to deploy with them.
2nd Script:
$registryPath = "HKLM\SOFTWARE\Policies\Google\Chrome\"
$Name = "CloudManagementEnrollmentToken"
$value = "----"
IF(!(Test-Path $registryPath))
{
New-Item -Path $registryPath -Force | Out-Null
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType SZ -Force | Out-Null} ELSE { New-ItemProperty -Path $registryPath -Name $name -Value $value
-PropertyType SZ -Force | Out-Null}
3rd Script:
$reg = Get-Itemproperty -Path "HKLM\SOFTWARE\Policies\Google\Chrome" -Name CloudManagementEnrollmentToken
if(-not($reg)){
New-Itemproperty -path "HKLM\SOFTWARE\Policies\Google\Chrome" -name "CloudManagementEnrollmentToken" -value "----" -PropertyType "SZ"
} else
{
Set-ItemProperty -path "HKLM\SOFTWARE\Policies\Google\Chrome" -name "CloudManagementEnrollmentToken" -value "----****e" -PropertyType "SZ"
I am sure my 2nd and 3rd script attempts are just written poorly, but I don't understand why the first script does not work when deploying via Intune.
Any tips or suggestions would be appreciated.

