Kaseya Community

PS syntax question for admin update

  • I am trying to change the e-mail address of a test user. I run the following command:

    $restResult = Invoke-RestMethod -Method PUT -Uri $VsaDomain -Headers @{'Authorization' = "Bearer $Token"} -ErrorAction Stop -Body $data -ContentType 'application/json'

    The value of $data is:

    $data = "{`"UserId`":`"9400405`",`"AdminName`":`"jtest`",`"Email`":`"dur@dur.com`",`"AdminPassword`":`"pwhash`",`"Admintype`":1,`"AdminScopeIds`":`"{`"11342431981191956441382221`", `"91318423222716256217953111`"}`",`"AdminRoleIds`":`"{`"233148332`", `"676244144}`",`"FirstName`":`"Joe`",`"LastName`":`"Test`"`"DefaultStaffOrgId`":`"99224151225115415317254167`",`"DefaultStaffDepartmentId`":`"71315821171821814714336411`"}"

    I'm getting the following error:

    Invoke-RestMethod : {
    "Result": [
    "Error converting value \"{\" to type 'System.Collections.Generic.IList`1[System.Decimal]'. Path 'AdminScopeIds
    line 1, position 161.",
    "After parsing a value an unexpected character was encountered: 1. Path 'AdminScopeIds', line 1, position 161."
    "ResponseCode": 0,
    "Status": "OK",
    "Error": "None"

    Do I need to escape the curly brackets around the AdminScopeIds and AdminRoleIds? What is the correct syntax for this in Powershell? Thanks.

  • Hi  

    Can you show us how you are executing this from the Kaseya VSA/Agent?

    Is this being called from a powershell file?

  • I am not running this from Kaseya, I am using a Powershell window on my own PC.