ARM : Set-AzureRmVMExtension -Settings throwing JObject error
Trying to test adding a extension to an existing ARM server. When using the settings prameter with a hashtable the function will throw a error:
Set-AzureRmVMExtension : Error reading JObject from JsonReader. Current JsonReader item is not an object: Null. Path '', line 1, position 4.
Tried both:
$config = @{
"AntimalwareEnabled" = "true";
"RealtimeProtectionEnabled" = "true";
"Exclusions" = @{
"Extensions" = ".txt";
"Paths"= "C:\Users";
"Processes"= "taskmgr.exe"
};
"ScheduledScanSettings" = @{
'isEnabled' = "true";
"day" = "7";
"time"= "120";
"scanType" = "Quick"
}
}
and
$config = @{
"AntimalwareEnabled" = "true";
"RealtimeProtectionEnabled" = "true"
}
with
Set-AzureRmVMExtension -location 'west europe' -ResourceGroupName 'arm' `
-VMName 'testserver' -Publisher 'Microsoft.Azure.Security' -ExtensionType 'IaaSAntimalware' `
-Name 'Microsoft.Azure.Security' -TypeHandlerVersion '1.1' -Settings $config
This does not seem to function as the documentation states at the moment.
@mortenlerudjordet Are you still experiencing issues with this? I'm seeing similar behaviour but am not a developer so don't have a clue how to fix it!
Have not tried again, just gave up. Though Set-AzureRmVMDiagnosticsExtension works on the latest version, so maybe Set-AzureRmVMExtension is fixed too?
@mortenlerudjordet it's OK now, i searched out this thread and tried as I want to change some antimalware settings, so like you did:
$config = @{
"AntimalwareEnabled" = "true";
"RealtimeProtectionEnabled" = "true";
"Exclusions" = @{
"Extensions" = "";
"Paths"= "c:\test";
"Processes"= ""
};
"ScheduledScanSettings" = @{
"isEnabled" = "true";
"day" = "7";
"time"= "120";
"scanType" = "Quick"
}
}
then run:
Set-AzureRmVMExtension -VMName $vm -Name "IaaSAntiMalware" -ResourceGroupName $RG -Settings $config -Publisher Microsoft.Azure.Security -ExtensionType IaaSAntimalware -Location eastasia -TypeHandlerVersion 1.3
everything seems fine đ
Good to hear. I'll close this then.
When adding an extension to an existing ARM vm using the SettingString parameter with the string argument type the cmdlet throws the error: Set-AzureRmVMExtension : Invalid property identifier character: â. Path '', line 1, position 1.
Arguments: $SettingsString = â{âAntimalwareEnabledâ: true,âRealtimeProtectionEnabledâ: true}â; $typeHandlerVerMjandMn is 1.5.
Cmdlet invoke:
Set-AzureRmVMExtension -ResourceGroupName $resourceGroupName -VMName $vmName -Name âIaaSAntimalwareâ
-Publisher âMicrosoft.Azure.Securityâ -ExtensionType âIaaSAntimalwareâ
-TypeHandlerVersion $typeHandlerVerMjandMn -SettingString $SettingsString -Location $location
Using the Settings parameter with its expected hash table argument type worked, as per SodaXu above.