azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

ARM : Set-AzureRmVMExtension -Settings throwing JObject error

Open mortenlerudjordet opened this issue 11 years ago • 5 comments

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 avatar Nov 16 '15 09:11 mortenlerudjordet

@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!

mark-wilson avatar May 12 '16 22:05 mark-wilson

Have not tried again, just gave up. Though Set-AzureRmVMDiagnosticsExtension works on the latest version, so maybe Set-AzureRmVMExtension is fixed too?

mortenlerudjordet avatar May 13 '16 11:05 mortenlerudjordet

@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 👍

SodaXu avatar Sep 28 '16 15:09 SodaXu

Good to hear. I'll close this then.

mortenlerudjordet avatar Sep 29 '16 10:09 mortenlerudjordet

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.

ChrisFg avatar Jul 23 '17 06:07 ChrisFg