diff --git a/scripts/bootstrap-ocsentinel-ninja.ps1 b/scripts/bootstrap-ocsentinel-ninja.ps1 index cf24198..9e71c99 100644 --- a/scripts/bootstrap-ocsentinel-ninja.ps1 +++ b/scripts/bootstrap-ocsentinel-ninja.ps1 @@ -18,6 +18,20 @@ $clientConfigPath = Join-Path $installRoot "config\ocsentinel-client.json" $secretScriptPath = Join-Path $installRoot "scripts\protect-ocsentinel-secret.ps1" $secretPath = "C:\ProgramData\OCSentinel\secrets\ocsentinel-upload-secret.dat" +# NinjaOne script variables are exposed as process environment variables. +if ([string]::IsNullOrWhiteSpace($WebhookUrl)) { + $WebhookUrl = $env:WebhookUrl +} + +if ([string]::IsNullOrWhiteSpace($SecretValue)) { + $SecretValue = $env:SecretValue +} + +$runInitialScan = $RunInitialStatusScan.IsPresent +if (-not $runInitialScan -and -not [string]::IsNullOrWhiteSpace($env:RunInitialStatusScan)) { + $runInitialScan = $env:RunInitialStatusScan -match '^(1|true|yes|on)$' +} + function Assert-ArtifactSignature { param([Parameter(Mandatory)][string]$ExecutablePath) @@ -108,7 +122,7 @@ if (-not [string]::IsNullOrWhiteSpace($SecretValue)) { } } -if ($RunInitialStatusScan) { +if ($runInitialScan) { if (-not (Test-Path -LiteralPath $monitorPath)) { throw "OCSentinel was installed, but the monitor script is missing." }