gavsto/AutomateAPI

Invoke-ControlCommand does not return results

Closed this issue · 3 comments

  1. Connect to your Control instance with a good user.
  2. Invoke-ControlCommand
  3. See errors
    image
  4. Get no response back from the session.
  5. Verify that the session got the command and returned a result
    image

text formatted error
Invoke-ControlAPIMaster : An error has been thrown.
at Invoke-ControlAPIMaster, C:\Program Files\WindowsPowerShell\Modules\automateapi\1.1.5\Public\Invoke-ControlAPIMaster.ps1: line 92
at Invoke-ControlCommand, C:\Program Files\WindowsPowerShell\Modules\automateapi\1.1.5\Public\Invoke-ControlCommand.ps1: line 253
at , : line 1
-->
--> {"errorType":"FaultException","message":"Sequence contains no elements","detail":null}
At C:\Program Files\WindowsPowerShell\Modules\automateapi\1.1.5\Public\Invoke-ControlCommand.ps1:253 char:27

  • ... $Events = Invoke-ControlAPIMaster -Arguments $RESTRequest
  •                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-ControlAPIMaster

WARNING: Issue with request, status: 500 Internal Server Error
WARNING: 1/3 retries, waiting 2s.
WARNING: Issue with request, status: 500 Internal Server Error
WARNING: 2/3 retries, waiting 4s.
WARNING: Issue with request, status: 500 Internal Server Error
WARNING: 3/3 retries, waiting 8s.
Invoke-ControlAPIMaster : Max retries hit. Status: InternalServerError Internal Server Error
At C:\Program Files\WindowsPowerShell\Modules\automateapi\1.1.5\Public\Invoke-ControlCommand.ps1:253 char:27

  • ... $Events = Invoke-ControlAPIMaster -Arguments $RESTRequest
  •                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-ControlAPIMaster

ConvertFrom-Json : Cannot bind argument to parameter 'InputObject' because it is null.
At C:\Program Files\WindowsPowerShell\Modules\automateapi\1.1.5\Public\Invoke-ControlAPIMaster.ps1:171 char:46

  •         $SCData=$(Try {$Result.Content | ConvertFrom-Json} Catch  ...
    
  •                                          ~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [ConvertFrom-Json], ParameterBindingValidationException
    • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertFromJsonCommand

Invoke-ControlCommand : Exception of type 'Microsoft.PowerShell.Commands.WriteErrorException' was thrown.
At line:1 char:1

  • Invoke-ControlCommand -SessionID '52b516b2-d857-4d61-adb8-e7a3bcbcdc8 ...
  •   + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
      + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-ControlCommand
    
    
guhri commented

I am getting the same error:

Invoke-ControlAPIMaster : An error has been thrown.
at Invoke-ControlAPIMaster, C:\Program
Files\WindowsPowerShell\Modules\AutomateAPI\Public\Invoke-ControlAPIMaster.ps1: line 92
at Invoke-ControlCommand, C:\Program
Files\WindowsPowerShell\Modules\AutomateAPI\Public\Invoke-ControlCommand.ps1: line 253
at Repair-AutomateAgent, C:\Program Files\WindowsPowerShell\Modules\AutomateAPI\Public\Repair-AutomateAgent.ps1:
line 150
at , : line 1
-->
--> {"errorType":"FaultException","message":"Sequence contains no elements","detail":null}
At C:\Program Files\WindowsPowerShell\Modules\AutomateAPI\Public\Invoke-ControlCommand.ps1:253 char:27

  • ... $Events = Invoke-ControlAPIMaster -Arguments $RESTRequest
  •                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-ControlAPIMaster

WARNING: Issue with request, status: 500 Internal Server Error
WARNING: 1/3 retries, waiting 2s.
WARNING: Issue with request, status: 500 Internal Server Error
WARNING: 2/3 retries, waiting 4s.
WARNING: Issue with request, status: 500 Internal Server Error
WARNING: 3/3 retries, waiting 8s.

I get the error when running the command: Get-AutomateComputer -Online $False | Compare-AutomateControlStatus | Repair-AutomateAgent -Action Restart

If I run the above but limit it down to a ComputerID I still get the error but the command shows as going through via Control log. When in bulk it errors out and does not look like the command gets sent through when checking the Control Command logs.

I just spent a couple days digging through the scripts to resolve this. It ended up being something simple, as ScreenConnect's one DB table was renamed. Just simply change "SessionConnectionEvent" to "SessionEvent" on line 245 in \1.1.5\Public\Invoke-ControlCommand.ps1 and then re-import the module. I