Persist Ninja context for scheduled scans
This commit is contained in:
@@ -164,8 +164,22 @@ if (-not [string]::IsNullOrWhiteSpace($WebhookUrl)) {
|
||||
$clientConfig = Get-Content -LiteralPath $clientConfigPath -Raw | ConvertFrom-Json
|
||||
$clientConfig.n8nWebhookUrl = $WebhookUrl
|
||||
$clientConfig.environment = "production"
|
||||
$ninjaContext = @(
|
||||
@{ EnvironmentName = "NINJA_ORGANIZATION_ID"; PropertyName = "ninjaOrganizationId" },
|
||||
@{ EnvironmentName = "NINJA_ORGANIZATION_NAME"; PropertyName = "ninjaOrganizationName" },
|
||||
@{ EnvironmentName = "NINJA_AGENT_MACHINE_ID"; PropertyName = "ninjaMachineId" },
|
||||
@{ EnvironmentName = "NINJA_AGENT_NODE_ID"; PropertyName = "ninjaNodeId" },
|
||||
@{ EnvironmentName = "NINJA_LOCATION_ID"; PropertyName = "ninjaLocationId" },
|
||||
@{ EnvironmentName = "NINJA_LOCATION_NAME"; PropertyName = "ninjaLocationName" }
|
||||
)
|
||||
foreach ($entry in $ninjaContext) {
|
||||
$value = [Environment]::GetEnvironmentVariable($entry.EnvironmentName, "Process")
|
||||
if (-not [string]::IsNullOrWhiteSpace($value)) {
|
||||
$clientConfig | Add-Member -NotePropertyName $entry.PropertyName -NotePropertyValue $value.Trim() -Force
|
||||
}
|
||||
}
|
||||
$clientConfig | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath $clientConfigPath -Encoding UTF8
|
||||
Write-Host "Configured OCSentinel upload endpoint."
|
||||
Write-Host "Configured OCSentinel upload endpoint and NinjaOne context."
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($SecretValue)) {
|
||||
|
||||
Reference in New Issue
Block a user