Custom Compliance Policy Error 65009 in Microsoft Intune
I created a custom compliance policy that searches for a specific registry key to check device compliance however, I am getting the following error 65009 (Invalid Json for the discovered setting). I checked the Json script in JSON Lint but there is no syntax error. I will add the PowerShell script and Json file below.
PowerShell script:
# Define the registry path and value name
$registryPath = “HKCU:SOFTWARETestCompliance”
$registryValueName = “TestValue”
# Check if the registry value exists
$registryValue = Get-ItemProperty -Path $registryPath -Name $registryValueName -ErrorAction SilentlyContinue
# Determine compliance status based on the registry value
$isCompliant = $null -ne $registryValue.$registryValueName
# Create a hash table with compliance details
$hash = @{
RegistryPath = $registryPath
ValueName = $registryValueName
IsCompliant = $isCompliant
}
# Return the hash table as a compact JSON string
return $hash | ConvertTo-Json -Compress
Json File:
{
“rules”: [
{
“settingName”: “IsCompliant”,
“operator”: “IsEquals”,
“dataType”: “boolean”,
“operand”: true,
“moreInfoUrl”: “https://learn.microsoft.com/en-us/mem/intune/fundamentals/deployment-plan-compliance-policies“,
“remediationStrings”: [
{
“language”: “en_US”,
“title”: “Compliance check failed”,
“description”: “The device is non-compliant.”
}
]
}
]
}
I created a custom compliance policy that searches for a specific registry key to check device compliance however, I am getting the following error 65009 (Invalid Json for the discovered setting). I checked the Json script in JSON Lint but there is no syntax error. I will add the PowerShell script and Json file below. PowerShell script: # Define the registry path and value name$registryPath = “HKCU:SOFTWARETestCompliance”$registryValueName = “TestValue”# Check if the registry value exists$registryValue = Get-ItemProperty -Path $registryPath -Name $registryValueName -ErrorAction SilentlyContinue# Determine compliance status based on the registry value$isCompliant = $null -ne $registryValue.$registryValueName# Create a hash table with compliance details$hash = @{ RegistryPath = $registryPath ValueName = $registryValueName IsCompliant = $isCompliant}# Return the hash table as a compact JSON stringreturn $hash | ConvertTo-Json -Compress Json File: { “rules”: [ { “settingName”: “IsCompliant”, “operator”: “IsEquals”, “dataType”: “boolean”, “operand”: true, “moreInfoUrl”: “https://learn.microsoft.com/en-us/mem/intune/fundamentals/deployment-plan-compliance-policies”, “remediationStrings”: [ { “language”: “en_US”, “title”: “Compliance check failed”, “description”: “The device is non-compliant.” } ] } ]} Read More