Open meanturtle opened 9 months ago
Line |
33 | $Data = Invoke-CWCWebRequest -Arguments $WebRequestArguments
| ~~~~~~~~~~~~
| An error has been thrown. --> --> {"errorType":"ArgumentException","message":"Unable to process arguments:
| Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name:
| index","detail":null} at Invoke-CWCWebRequest,
| C:\Users\Documents\PowerShell\Modules\ConnectWiseControlAPI\0.3.5.0\Private\Invoke-CWCWebRequest.ps1: line 25 at Get-CWCSession, C:\Users\Documents\PowerShell\Modules\ConnectWiseControlAPI\0.3.5.0\Public\PageService\Get-CWCSession.ps1: line 33 at
It's not pretty, but I found updating Get-CWCSession.ps1 with the below has worked for me with the same results as previously. So no modification to any implementations you have already coded :).
function Get-CWCSession {
[CmdletBinding()]
param (
[Parameter(Mandatory=$True)]
[ValidateSet('Support','Access','Meeting')]
$Type,
[string]$Group = $script:defaultGroup,
[string]$Search,
[int]$Limit
)
$Endpoint = 'Services/PageService.ashx/GetLiveData'
switch($Type){
'Support' { $Number = 0 }
'Meeting' { $Number = 1 }
'Access' { $Number = 2 }
default { return Write-Error "Unknown Type, $Type" }
}
#$Body = ConvertTo-Json @($Number,@($Group),$Search,$null,$Limit)
Write-Debug $Group
$Body = @"
[
{
`"HostSessionInfo`": {
`"sessionType`": 2,
`"sessionGroupPathParts`": [
`"$Group`"
],
`"filter`": `"$Search`",
`"findSessionID`": null,
`"sessionLimit`": 1000
},
`"ActionCenterInfo`": {}
},
0
]
"@
Write-Verbose $Body
$WebRequestArguments = @{
Endpoint = $Endpoint
Body = $Body
Method = 'Post'
}
$Data = Invoke-CWCWebRequest -Arguments $WebRequestArguments
$Data.ResponseInfoMap.HostSessionInfo.sessions
#$Data.sessions
}
Thank you. That works perfectly. Im back in action.
Thank you alot !
Thank you @twistedpro You resolved my issue too.
It looks like in the latest version of Connectwise Control the following endpoint has changed name.
$Endpoint = 'Services/PageService.ashx/GetHostSessionInfo'
$Endpoint = 'Services/PageService.ashx/GetLiveData'
I have updated the Get-CWCSession.ps1 to see can I get it to work but receiving an error index out of range.
Possibly due to action center in the payload: [{"HostSessionInfo":{"sessionType":2,"sessionGroupPathParts":["All Machines"],"filter":"","findSessionID":"GUIDKEY","sessionLimit":1000},"ActionCenterInfo":{}},340713519]
Have tried changing $Body = ConvertTo-Json @($Number,@($Group),$Search,$null,$Limit)
to
$Body = ConvertTo-Json @($Number,@($Group),$Search,$null,$Limit),($null) and different variations but my knowledge of how that works is limited