Fix Windows RDP collectors startup
This commit is contained in:
@@ -301,6 +301,9 @@ function Copy-ActivityWatchCollectorAssets {
|
|||||||
$resolvedRules = Resolve-Path -LiteralPath $CustomRulesSource -ErrorAction Stop
|
$resolvedRules = Resolve-Path -LiteralPath $CustomRulesSource -ErrorAction Stop
|
||||||
Copy-Item -LiteralPath $resolvedRules.Path -Destination $rulesTarget -Force
|
Copy-Item -LiteralPath $resolvedRules.Path -Destination $rulesTarget -Force
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Copy-Item -LiteralPath $exampleRulesTarget -Destination $rulesTarget -Force
|
||||||
|
}
|
||||||
|
|
||||||
if ($CustomPolicySource) {
|
if ($CustomPolicySource) {
|
||||||
$resolvedPolicy = Resolve-Path -LiteralPath $CustomPolicySource -ErrorAction Stop
|
$resolvedPolicy = Resolve-Path -LiteralPath $CustomPolicySource -ErrorAction Stop
|
||||||
@@ -718,11 +721,11 @@ function Start-CollectorScriptIfNeeded {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
$staParam = if (`$ScriptPath -like "*endpoint-signals*") { "-STA" } else { $null }
|
`$staParam = if (`$ScriptPath -like "*endpoint-signals*") { "-STA" } else { `$null }
|
||||||
$argumentList = @('-NoProfile', '-WindowStyle', 'Hidden', '-ExecutionPolicy', 'Bypass')
|
`$argumentList = @('-NoProfile', '-WindowStyle', 'Hidden', '-ExecutionPolicy', 'Bypass')
|
||||||
if ($staParam) { $argumentList += $staParam }
|
if (`$staParam) { `$argumentList += `$staParam }
|
||||||
$argumentList += @('-File', `$ScriptPath, '-ConfigPath', `$ConfigPath)
|
`$argumentList += @('-File', `$ScriptPath, '-ConfigPath', `$ConfigPath)
|
||||||
Start-Process -FilePath `$PowerShellExe -ArgumentList $argumentList -WindowStyle Hidden
|
Start-Process -FilePath `$PowerShellExe -ArgumentList `$argumentList -WindowStyle Hidden
|
||||||
}
|
}
|
||||||
|
|
||||||
`$config = Get-DeploymentConfig -Path `$ConfigPath
|
`$config = Get-DeploymentConfig -Path `$ConfigPath
|
||||||
|
|||||||
@@ -701,13 +701,26 @@ function Ensure-Bucket {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Invoke-RestMethod -Method Get -Uri "$($script:ApiBase)/buckets/$BucketId" | Out-Null
|
||||||
|
$script:KnownBuckets[$BucketId] = $true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
}
|
||||||
|
|
||||||
$body = @{
|
$body = @{
|
||||||
client = $ClientName
|
client = $ClientName
|
||||||
type = $BucketType
|
type = $BucketType
|
||||||
hostname = $script:Hostname
|
hostname = $script:Hostname
|
||||||
} | ConvertTo-Json -Compress
|
} | ConvertTo-Json -Compress
|
||||||
|
|
||||||
Invoke-RestMethod -Method Post -Uri "$($script:ApiBase)/buckets/$BucketId" -ContentType 'application/json' -Body $body | Out-Null
|
try {
|
||||||
|
Invoke-RestMethod -Method Post -Uri "$($script:ApiBase)/buckets/$BucketId" -ContentType 'application/json; charset=utf-8' -Body ([Text.Encoding]::UTF8.GetBytes($body)) | Out-Null
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Invoke-RestMethod -Method Get -Uri "$($script:ApiBase)/buckets/$BucketId" | Out-Null
|
||||||
|
}
|
||||||
$script:KnownBuckets[$BucketId] = $true
|
$script:KnownBuckets[$BucketId] = $true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
[string]$ConfigPath = 'C:\ProgramData\AWatch-rus\deployment-config.json',
|
[string]$ConfigPath = 'C:\ProgramData\AWatch-rus\deployment-config.json',
|
||||||
[string]$ServerHost,
|
[string]$ServerHost,
|
||||||
@@ -54,13 +54,32 @@ function Ensure-Bucket {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Invoke-RestMethod -Method Get -Uri "$($script:ApiBase)/buckets/$BucketId" | Out-Null
|
||||||
|
$script:KnownBuckets[$BucketId] = $true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
}
|
||||||
|
|
||||||
$body = @{
|
$body = @{
|
||||||
client = $ClientName
|
client = $ClientName
|
||||||
type = $BucketType
|
type = $BucketType
|
||||||
hostname = $script:Hostname
|
hostname = $script:Hostname
|
||||||
} | ConvertTo-Json -Compress
|
} | ConvertTo-Json -Compress
|
||||||
|
|
||||||
Invoke-AwJsonPost -Uri "$($script:ApiBase)/buckets/$BucketId" -Json $body
|
try {
|
||||||
|
Invoke-AwJsonPost -Uri "$($script:ApiBase)/buckets/$BucketId" -Json $body
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
try {
|
||||||
|
Invoke-RestMethod -Method Get -Uri "$($script:ApiBase)/buckets/$BucketId" | Out-Null
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-EndpointLog "Bucket create/check failed for ${BucketId}: $($_.Exception.Message)"
|
||||||
|
throw
|
||||||
|
}
|
||||||
|
}
|
||||||
$script:KnownBuckets[$BucketId] = $true
|
$script:KnownBuckets[$BucketId] = $true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,13 +64,37 @@ function Ensure-Bucket {
|
|||||||
[string]$ClientName,
|
[string]$ClientName,
|
||||||
[string]$BucketType
|
[string]$BucketType
|
||||||
)
|
)
|
||||||
if ($script:KnownBuckets.ContainsKey($BucketId)) { return }
|
|
||||||
|
if ($script:KnownBuckets.ContainsKey($BucketId)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Invoke-RestMethod -Method Get -Uri "$($script:ApiBase)/buckets/$BucketId" | Out-Null
|
||||||
|
$script:KnownBuckets[$BucketId] = $true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
}
|
||||||
|
|
||||||
$body = @{
|
$body = @{
|
||||||
client = $ClientName
|
client = $ClientName
|
||||||
type = $BucketType
|
type = $BucketType
|
||||||
hostname = $script:Hostname
|
hostname = $script:Hostname
|
||||||
} | ConvertTo-Json -Compress
|
} | ConvertTo-Json -Compress
|
||||||
Invoke-AwJsonPost -Uri "$($script:ApiBase)/buckets/$BucketId" -Json $body
|
|
||||||
|
try {
|
||||||
|
Invoke-AwJsonPost -Uri "$($script:ApiBase)/buckets/$BucketId" -Json $body
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
try {
|
||||||
|
Invoke-RestMethod -Method Get -Uri "$($script:ApiBase)/buckets/$BucketId" | Out-Null
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-FileCollectorLog "Bucket create/check failed for ${BucketId}: $($_.Exception.Message)"
|
||||||
|
throw
|
||||||
|
}
|
||||||
|
}
|
||||||
$script:KnownBuckets[$BucketId] = $true
|
$script:KnownBuckets[$BucketId] = $true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,12 @@ function Ensure-Bucket {
|
|||||||
hostname = $HostnameValue
|
hostname = $HostnameValue
|
||||||
} | ConvertTo-Json -Compress
|
} | ConvertTo-Json -Compress
|
||||||
|
|
||||||
Invoke-AwJsonPost -Uri "$ApiBase/buckets/$BucketId" -Json $body
|
try {
|
||||||
|
Invoke-AwJsonPost -Uri "$ApiBase/buckets/$BucketId" -Json $body
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Invoke-RestMethod -Method Get -Uri "$ApiBase/buckets/$BucketId" | Out-Null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-SessionRecords {
|
function Get-SessionRecords {
|
||||||
|
|||||||
Reference in New Issue
Block a user