Legacy Dev Forum Posts

 View Only

Sign Up

Powershell and CLI with updating Auto Answer

  • 1.  Powershell and CLI with updating Auto Answer

    Posted 06-05-2025 18:28

    Kyle_Holbrook | 2023-10-05 03:28:42 UTC | #1

    Hey All I am having an issue. I am trying to update autoanswer of one user using the CLI. My code is:

    echo '{acdAutoAnswer": "true"}' | gc.exe users update $userid

    and my output is as follow:

    gc.exe : { At line:2 char:36

    • ... "true"}' | gc.exe users update f6ac8a19-dd74-495b-aa8f-68a04ca28ada
    • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        • CategoryInfo : NotSpecified: ({:String) [], RemoteException
        • FullyQualifiedErrorId : NativeCommandError

    "message": "The request could not be understood by the server due to malformed syntax.", "code": "bad.request", "status": 400, "contextId": "af0c9999-1156-4693-a45f-f318d9c7530e", "details": [], "errors": [] }

    Any ideas?


    Jerome.Saint-Marc | 2023-10-05 07:12:27 UTC | #2

    Hello,

    The "gc.exe users update $userid" coresponds to a PATCH /api/v2/users/{userId} version is a mandatory input parameter.

    I mean the current version number you see when requesting user info: "gc.exe users get $userid" The command would then be (assuming you have stored current version number in something like $usercurrentversion): echo '{"acdAutoAnswer": true, "version": '$usercurrentversion'}' | gc.exe users update $userid

    But you can use another endpoint if you are trying to update multiple users at once (or even just one). The maximum is 50 per requests. This is using "gc.exe users bulk update" - which corresponds to: PATCH /api/v2/users/bulk echo '[{"id": "'$userid'", "acdAutoAnswer": true}]' | gc.exe users bulk update

    Regards,


    Kyle_Holbrook | 2023-10-05 13:41:11 UTC | #3

    I actually figured this out after I posted this. my previous script spits out a csv with who needs auto answers set up and here is my code that is currently working: $autoanswer = import-csv csvfilehere

    $userid = (gc.exe users list -a

    ConvertFrom-Json)

    Where-Object email -eq $autoanswer.email

    Select-Object -ExpandProperty id

    $version = (gc.exe users list -a

    ConvertFrom-Json)

    Where-Object email -eq $autoanswer.email

    Select-Object -ExpandProperty version

    $Raw = @{ acdAutoAnswer = "true" version = "$version" }

    $json = $raw

    ConvertTo-Json

    echo $json

    gc.exe users update $userid

    I will wrap this in a foreach to iterate through each user who needs autoanswer.


    system | 2023-11-04 13:40:18 UTC | #4

    This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 22372