Skip to content
Open
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
24 changes: 15 additions & 9 deletions CWCPoSh.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -230,12 +230,18 @@ 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

$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 = @()
Expand All @@ -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)"
Expand Down Expand Up @@ -382,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"
Expand Down Expand Up @@ -462,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"
Expand Down Expand Up @@ -554,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)
Expand Down Expand Up @@ -626,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"
Expand Down Expand Up @@ -715,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"
Expand All @@ -724,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 {
Expand Down