gavsto / AutomateAPI

Powershell Module for the ConnectWise Automate API
GNU General Public License v3.0
84 stars 48 forks source link

Invoke-ControlCommand does not return results #75

Closed ChrisCalv closed 1 year ago

ChrisCalv commented 1 year ago
  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
ChrisCalv commented 1 year ago

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

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

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

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

guhri commented 1 year ago

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

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.

higherinfogroup commented 1 year ago

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