Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ConnectWiseControlAPI/ConnectWiseControlAPI.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @()
Expand Down Expand Up @@ -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 = @()
Expand Down
1 change: 1 addition & 0 deletions ConnectWiseControlAPI/Private/Invoke-CWCWebRequest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
26 changes: 26 additions & 0 deletions ConnectWiseControlAPI/Public/PageService/Add-CWCSessionNote.ps1
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 27 additions & 5 deletions ConnectWiseControlAPI/Public/PageService/Get-CWCSession.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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 = @{
Expand All @@ -28,5 +49,6 @@ function Get-CWCSession {
}

$Data = Invoke-CWCWebRequest -Arguments $WebRequestArguments
$Data.sessions
}
$Data.ResponseInfoMap.HostSessionInfo.sessions
#$Data.sessions
}
Original file line number Diff line number Diff line change
@@ -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
})
}
27 changes: 27 additions & 0 deletions ConnectWiseControlAPI/Public/PageService/Remove-CWCSessionNote.ps1
Original file line number Diff line number Diff line change
@@ -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

}
Original file line number Diff line number Diff line change
@@ -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

}
2 changes: 1 addition & 1 deletion ConnectWiseControlAPI/en-US/ConnectWiseControlAPI-help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code>Get-CWCAccessSessions -Type 'Access' -Search 'server1' -Limit 10</dev:code>
<dev:code>Get-CWCSessions -Type 'Access' -Search 'server1' -Limit 10</dev:code>
<dev:remarks>
<maml:para>Will return the first 10 access sessions that match 'server1'.</maml:para>
</dev:remarks>
Expand Down