From 5bc5f744b3ee0a12c1d9c417ad41fc09fa0ce8b1 Mon Sep 17 00:00:00 2001 From: Bobs16 Date: Wed, 24 Apr 2019 09:22:19 -0700 Subject: [PATCH 1/4] Update CWCPoSh.psm1 Temp fix for authorization header. CWC bug report : https://control.product.connectwise.com/communities/6/topics/2324-addeventtosessions-authentication-changes-190232347027# --- CWCPoSh.psm1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CWCPoSh.psm1 b/CWCPoSh.psm1 index d1be96a..38ac8cd 100644 --- a/CWCPoSh.psm1 +++ b/CWCPoSh.psm1 @@ -236,6 +236,12 @@ function Invoke-CWCCommand { $origin = New-Object -Type DateTime -ArgumentList 1970, 1, 1, 0, 0, 0, 0 $URI = "$Server/Services/PageService.ashx/AddEventToSessions" + + #Create authorization header + $key = "$($Credentials.UserName):$($Credentials.GetNetworkCredential().password)" + $headers = @{ + "Authorization" = "Basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($key)))" + } # Format command $FormattedCommand = @() @@ -252,7 +258,7 @@ function Invoke-CWCCommand { # Issue command try { - $null = Invoke-RestMethod -Uri $URI -Method Post -Credential $Credentials -ContentType "application/json" -Body $Body + $null = Invoke-RestMethod -Uri $URI -Method Post -Headers $headers -Credential $Credentials -ContentType "application/json" -Body $Body } catch { Write-Error "$(($_.ErrorDetails | ConvertFrom-Json).message)" From 1d8392d989586e2db4aba88189401a0b399566ec Mon Sep 17 00:00:00 2001 From: RobinsonLevi Date: Tue, 27 Aug 2019 09:44:38 -0700 Subject: [PATCH 2/4] Update CWCPoSh.psm1 Remove Cred comment. --- CWCPoSh.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CWCPoSh.psm1 b/CWCPoSh.psm1 index 38ac8cd..cc56014 100644 --- a/CWCPoSh.psm1 +++ b/CWCPoSh.psm1 @@ -100,7 +100,7 @@ function Get-CWCLastContact { if($Password) { $secpasswd = ConvertTo-SecureString $Password -AsPlainText -Force $Credentials = New-Object System.Management.Automation.PSCredential ($User, $secpasswd) - Write-Warning "Switch to -Credentials [PSCredential] authentication method." + #Write-Warning "Switch to -Credentials [PSCredential] authentication method." } $Body = ConvertTo-Json @($Group,$GUID) From 050cbbc91827b7848f6f940323e49fa4569a320b Mon Sep 17 00:00:00 2001 From: RobinsonLevi Date: Tue, 27 Aug 2019 09:47:28 -0700 Subject: [PATCH 3/4] Update CWCPoSh.psm1 --- CWCPoSh.psm1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CWCPoSh.psm1 b/CWCPoSh.psm1 index cc56014..af071de 100644 --- a/CWCPoSh.psm1 +++ b/CWCPoSh.psm1 @@ -230,7 +230,7 @@ function Invoke-CWCCommand { if($Password) { $secpasswd = ConvertTo-SecureString $Password -AsPlainText -Force $Credentials = New-Object System.Management.Automation.PSCredential ($User, $secpasswd) - Write-Warning "Switch to -Credentials [PSCredential] authentication method." + #Write-Warning "Switch to -Credentials [PSCredential] authentication method." } $origin = New-Object -Type DateTime -ArgumentList 1970, 1, 1, 0, 0, 0, 0 @@ -388,7 +388,7 @@ function Get-CWCSessions { if($Password) { $secpasswd = ConvertTo-SecureString $Password -AsPlainText -Force $Credentials = New-Object System.Management.Automation.PSCredential ($User, $secpasswd) - Write-Warning "Switch to -Credentials [PSCredential] authentication method." + #Write-Warning "Switch to -Credentials [PSCredential] authentication method." } $URI = "$Server/Services/PageService.ashx/GetHostSessionInfo" @@ -468,7 +468,7 @@ function Remove-CWCSession { if($Password) { $secpasswd = ConvertTo-SecureString $Password -AsPlainText -Force $Credentials = New-Object System.Management.Automation.PSCredential ($User, $secpasswd) - Write-Warning "Switch to -Credentials [PSCredential] authentication method." + #Write-Warning "Switch to -Credentials [PSCredential] authentication method." } $URI = "$Server/Services/PageService.ashx/AddEventToSessions" @@ -560,7 +560,7 @@ function Update-CWCSessionName { if($Password) { $secpasswd = ConvertTo-SecureString $Password -AsPlainText -Force $Credentials = New-Object System.Management.Automation.PSCredential ($User, $secpasswd) - Write-Warning "Switch to -Credentials [PSCredential] authentication method." + #Write-Warning "Switch to -Credentials [PSCredential] authentication method." } $Body = ConvertTo-Json @($Group,$GUID,$NewName) @@ -632,7 +632,7 @@ function Invoke-CWCWake { if($Password) { $secpasswd = ConvertTo-SecureString $Password -AsPlainText -Force $Credentials = New-Object System.Management.Automation.PSCredential ($User, $secpasswd) - Write-Warning "Switch to -Credentials [PSCredential] authentication method." + #Write-Warning "Switch to -Credentials [PSCredential] authentication method." } $URI = "$Server/Services/PageService.ashx/AddEventToSessions" @@ -721,7 +721,7 @@ function Get-CWCSessionDetail { if($Password) { $secpasswd = ConvertTo-SecureString $Password -AsPlainText -Force $Credentials = New-Object System.Management.Automation.PSCredential ($User, $secpasswd) - Write-Warning "Switch to -Credentials [PSCredential] authentication method." + #Write-Warning "Switch to -Credentials [PSCredential] authentication method." } $URI = "$Server/Services/PageService.ashx/GetSessionDetails" From 8f35990193a086786ac26483a1dabb899124528e Mon Sep 17 00:00:00 2001 From: RobinsonLevi Date: Fri, 6 Sep 2019 09:50:14 -0700 Subject: [PATCH 4/4] Update CWCPoSh.psm1 --- CWCPoSh.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CWCPoSh.psm1 b/CWCPoSh.psm1 index af071de..b490173 100644 --- a/CWCPoSh.psm1 +++ b/CWCPoSh.psm1 @@ -730,7 +730,7 @@ function Get-CWCSessionDetail { Write-Verbose $Body try { - $Data = Invoke-RestMethod -Uri $URI -Method Post -Credential $Credentials -ContentType "application/json; charset=utf-8" -Body $Body -Verbose + $Data = Invoke-RestMethod -Uri $URI -Method Post -Credential $Credentials -ContentType "application/json; charset=utf-8" -Body $Body return $Data } catch {