diff --git a/ConnectWiseControlAPI/ConnectWiseControlAPI.psd1 b/ConnectWiseControlAPI/ConnectWiseControlAPI.psd1 index 6e74c82..4557ac9 100644 --- a/ConnectWiseControlAPI/ConnectWiseControlAPI.psd1 +++ b/ConnectWiseControlAPI/ConnectWiseControlAPI.psd1 @@ -12,7 +12,7 @@ RootModule = 'ConnectWiseControlAPI.psm1' # Version number of this module. - ModuleVersion = '0.3.3.0' + ModuleVersion = '0.3.5.0' # Supported PSEditions # CompatiblePSEditions = @() @@ -69,7 +69,7 @@ # NestedModules = @() # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. - FunctionsToExport = @('Get-CWCAuditInfo','Get-CWCAuditLog','Connect-CWC','Get-CWCLauncURL','Add-CWCRemoteWorkforceRequiredRole','New-CWCRemoteWorkforceAssignment','New-CWCMFA','Get-CWCLastContact','Get-CWCSession','Get-CWCSessionDetail','Invoke-CWCCommand','Invoke-CWCWake','New-CWCAccessToken','Remove-CWCSession','Update-CWCCustomProperty','Update-CWCSessionName','Get-CWCSecurityConfigurationInfo','New-CWCUser','Remove-CWCUser','Update-CWCUser','Get-CWCSessionGroup') + FunctionsToExport = @('Get-CWCAuditInfo','Get-CWCAuditLog','Connect-CWC','Get-CWCLauncURL','Add-CWCRemoteWorkforceRequiredRole','Add-CWCSessionNote','Remove-CWCAllSessionNotes','Remove-CWCSessionNote','New-CWCRemoteWorkforceAssignment','New-CWCMFA','Get-CWCLastContact','Get-CWCSession','Get-CWCSessionDetail','Invoke-CWCCommand','Invoke-CWCWake','New-CWCAccessToken','Remove-CWCSession','Update-CWCCustomProperty','Update-CWCSessionName','Get-CWCSecurityConfigurationInfo','New-CWCUser','Remove-CWCUser','Update-CWCUser','Get-CWCSessionGroup') # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. CmdletsToExport = @() diff --git a/ConnectWiseControlAPI/Private/Invoke-CWCWebRequest.ps1 b/ConnectWiseControlAPI/Private/Invoke-CWCWebRequest.ps1 index 2d49fa9..8437fc4 100644 --- a/ConnectWiseControlAPI/Private/Invoke-CWCWebRequest.ps1 +++ b/ConnectWiseControlAPI/Private/Invoke-CWCWebRequest.ps1 @@ -20,6 +20,7 @@ $Arguments.Headers = $script:CWCServerConnection.Headers $Arguments.UseBasicParsing = $true Write-Debug "Arguments: $($Arguments | ConvertTo-Json)" + Write-Host "Arguments: $($Arguments | ConvertTo-Json)" # Issue request try { $Result = Invoke-WebRequest @Arguments } diff --git a/ConnectWiseControlAPI/Public/PageService/Add-CWCSessionNote.ps1 b/ConnectWiseControlAPI/Public/PageService/Add-CWCSessionNote.ps1 new file mode 100644 index 0000000..8253008 --- /dev/null +++ b/ConnectWiseControlAPI/Public/PageService/Add-CWCSessionNote.ps1 @@ -0,0 +1,26 @@ +function Add-CWCSessionNote { + [CmdletBinding(SupportsShouldProcess)] + param( + [Parameter(Mandatory=$True)] + [guid]$SessionId, + [Parameter(Mandatory=$True)] + [string]$Note, + [string[]]$Group = 'All Machines' + ) + + $Endpoint = 'Services/PageService.ashx/AddSessionEvents' + + $params = @{ + SessionID = $SessionId + EventType = 32 + Data = $Note + } + $Body = ConvertTo-Json @($Group,@($params)) + + $WebRequestArguments = @{ + Endpoint = $Endpoint + Body = $Body + Method = 'Post' + } + $Data = Invoke-CWCWebRequest -Arguments $WebRequestArguments +} \ No newline at end of file diff --git a/ConnectWiseControlAPI/Public/PageService/Get-CWCLastContact.ps1 b/ConnectWiseControlAPI/Public/PageService/Get-CWCLastContact.ps1 index ca0f118..f3d7845 100644 --- a/ConnectWiseControlAPI/Public/PageService/Get-CWCLastContact.ps1 +++ b/ConnectWiseControlAPI/Public/PageService/Get-CWCLastContact.ps1 @@ -29,7 +29,7 @@ if ($GuestSessionEvents) { # Get connection events - $LatestEvent = $GuestSessionEvents | Where-Object { + $LatestEvent = $GuestSessionEvents | Where-Object { $_.EventType -in (10, 11) -and $_.ConnectionID -NotIn $GuestSessionConnections.ConnectionID } | Sort-Object time | Select-Object -First 1 diff --git a/ConnectWiseControlAPI/Public/PageService/Get-CWCSession.ps1 b/ConnectWiseControlAPI/Public/PageService/Get-CWCSession.ps1 index f1f3ac3..de0b7a4 100644 --- a/ConnectWiseControlAPI/Public/PageService/Get-CWCSession.ps1 +++ b/ConnectWiseControlAPI/Public/PageService/Get-CWCSession.ps1 @@ -4,12 +4,12 @@ function Get-CWCSession { [Parameter(Mandatory=$True)] [ValidateSet('Support','Access','Meeting')] $Type, - [string]$Group = 'All Machines', + [string]$Group = $script:defaultGroup, [string]$Search, [int]$Limit ) - $Endpoint = 'Services/PageService.ashx/GetHostSessionInfo' + $Endpoint = 'Services/PageService.ashx/GetLiveData' switch($Type){ 'Support' { $Number = 0 } @@ -18,7 +18,28 @@ function Get-CWCSession { default { return Write-Error "Unknown Type, $Type" } } - $Body = ConvertTo-Json @($Number,@($Group),$Search,$null,$Limit) + #$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 = @{ @@ -28,5 +49,6 @@ function Get-CWCSession { } $Data = Invoke-CWCWebRequest -Arguments $WebRequestArguments - $Data.sessions -} + $Data.ResponseInfoMap.HostSessionInfo.sessions + #$Data.sessions +} \ No newline at end of file diff --git a/ConnectWiseControlAPI/Public/PageService/Remove-CWCAllSessionNotes.ps1 b/ConnectWiseControlAPI/Public/PageService/Remove-CWCAllSessionNotes.ps1 new file mode 100644 index 0000000..55c0fc5 --- /dev/null +++ b/ConnectWiseControlAPI/Public/PageService/Remove-CWCAllSessionNotes.ps1 @@ -0,0 +1,14 @@ +function Remove-CWCAllSessionNotes { + [CmdletBinding(SupportsShouldProcess)] + param( + [Parameter(Mandatory=$True)] + [guid]$SessionId, + [string[]]$Group = 'All Machines' + ) + + $sesstionDetails = Get-CWCSessionDetail -GUID $SessionId + $notes = $sesstionDetails.Events | Where-Object {$_.EventType -eq 32} + $notes.ForEach({ + Remove-CWCSessionNote -SessionId $SessionId -NoteEventId $_.EventID -Group $Group + }) +} \ No newline at end of file diff --git a/ConnectWiseControlAPI/Public/PageService/Remove-CWCSessionNote.ps1 b/ConnectWiseControlAPI/Public/PageService/Remove-CWCSessionNote.ps1 new file mode 100644 index 0000000..bd22391 --- /dev/null +++ b/ConnectWiseControlAPI/Public/PageService/Remove-CWCSessionNote.ps1 @@ -0,0 +1,27 @@ +function Remove-CWCSessionNote { + [CmdletBinding(SupportsShouldProcess)] + param( + [Parameter(Mandatory=$True)] + [guid]$SessionId, + [guid]$NoteEventId, + [string[]]$Group = 'All Machines' + ) + + $Endpoint = 'Services/PageService.ashx/AddSessionEvents' + + $params = @{ + SessionID = $SessionId + EventType = 1 + CorrelationEventID = $NoteEventId + } + $Body = ConvertTo-Json @($Group,@($params)) + Write-Host $Body + + $WebRequestArguments = @{ + Endpoint = $Endpoint + Body = $Body + Method = 'Post' + } + $Data = Invoke-CWCWebRequest -Arguments $WebRequestArguments + +} \ No newline at end of file diff --git a/ConnectWiseControlAPI/Public/PageService/Remove-CWCSessionNotes.ps1 b/ConnectWiseControlAPI/Public/PageService/Remove-CWCSessionNotes.ps1 new file mode 100644 index 0000000..bd22391 --- /dev/null +++ b/ConnectWiseControlAPI/Public/PageService/Remove-CWCSessionNotes.ps1 @@ -0,0 +1,27 @@ +function Remove-CWCSessionNote { + [CmdletBinding(SupportsShouldProcess)] + param( + [Parameter(Mandatory=$True)] + [guid]$SessionId, + [guid]$NoteEventId, + [string[]]$Group = 'All Machines' + ) + + $Endpoint = 'Services/PageService.ashx/AddSessionEvents' + + $params = @{ + SessionID = $SessionId + EventType = 1 + CorrelationEventID = $NoteEventId + } + $Body = ConvertTo-Json @($Group,@($params)) + Write-Host $Body + + $WebRequestArguments = @{ + Endpoint = $Endpoint + Body = $Body + Method = 'Post' + } + $Data = Invoke-CWCWebRequest -Arguments $WebRequestArguments + +} \ No newline at end of file diff --git a/ConnectWiseControlAPI/en-US/ConnectWiseControlAPI-help.xml b/ConnectWiseControlAPI/en-US/ConnectWiseControlAPI-help.xml index 0f2c255..484213d 100644 --- a/ConnectWiseControlAPI/en-US/ConnectWiseControlAPI-help.xml +++ b/ConnectWiseControlAPI/en-US/ConnectWiseControlAPI-help.xml @@ -871,7 +871,7 @@ -------------------------- EXAMPLE 1 -------------------------- - Get-CWCAccessSessions -Type 'Access' -Search 'server1' -Limit 10 + Get-CWCSessions -Type 'Access' -Search 'server1' -Limit 10 Will return the first 10 access sessions that match 'server1'.