Automox Deployment
Deploy Akto Endpoint Shield on Windows endpoints using an Automox Worklet policy with a customer-specific Inno Setup installer.
Important: Automox runs as SYSTEM
Prerequisites
Deployment Steps
3
Evaluation code
# Akto Endpoint Shield - Evaluation
# Exit 0 = compliant, Exit 1 = needs remediation
$pf64 = ${env:ProgramW6432}
if (-not $pf64) { $pf64 = "C:\Program Files" }
$binCandidates = @(
(Join-Path $pf64 "Akto Endpoint Shield\akto-endpoint-shield.exe")
(Join-Path $pf64 "MCP Endpoint Shield\akto-endpoint-shield.exe")
)
$binPath = $binCandidates | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
$arp = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" -ErrorAction SilentlyContinue |
Where-Object { $_.DisplayName -like "*Endpoint*Shield*" -or $_.DisplayName -like "*Akto*Endpoint*" }
$agentTask = Get-ScheduledTask -TaskName "MCPEndpointShieldAgent" -ErrorAction SilentlyContinue
$userHasToken = $false
$agentHealthy = $true
Get-CimInstance Win32_UserProfile -ErrorAction SilentlyContinue | ForEach-Object {
if ($_.Special -or -not $_.LocalPath) { return }
if ($_.SID -notmatch '^S-1-5-21-') { return }
$userCfg = Join-Path $_.LocalPath ".akto-endpoint-shield\config\config.env"
if ((Test-Path -LiteralPath $userCfg) -and (Select-String -LiteralPath $userCfg -Pattern '^AKTO_API_TOKEN=' -Quiet)) {
$userHasToken = $true
$agentLog = Join-Path $_.LocalPath "AppData\Local\akto-endpoint-shield\logs\agent.log"
if (-not (Test-Path -LiteralPath $agentLog)) {
$agentHealthy = $false
return
}
$startupLine = Select-String -LiteralPath $agentLog -Pattern "startup env" -ErrorAction SilentlyContinue |
Select-Object -Last 1
if (-not $startupLine) {
$agentHealthy = $false
return
}
if ($startupLine.Line -match 'AKTO_API_TOKEN.*\(not set\)') {
$agentHealthy = $false
return
}
$cfgTime = (Get-Item -LiteralPath $userCfg).LastWriteTime
$logTime = (Get-Item -LiteralPath $agentLog).LastWriteTime
if ($cfgTime -gt $logTime) {
$agentHealthy = $false
}
}
}
if ($binPath -and $arp -and $agentTask -and $userHasToken -and $agentHealthy) {
Write-Output "Compliant: $binPath"
exit 0
}
Write-Output "Non-compliant. binary=$([bool]$binPath) task=$([bool]$agentTask) userToken=$userHasToken agentHealthy=$agentHealthy"
exit 1
4
Remediation code
# Akto Endpoint Shield - Remediation (install + config propagation)
$fileName = "akto-endpoint-shield-setup-1.1.5.exe"
$arguments = "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /LOG=C:\Windows\Temp\akto-endpoint-shield-install.log"
$pf64 = ${env:ProgramW6432}
if (-not $pf64) { $pf64 = "C:\Program Files" }
$bin1 = Join-Path $pf64 "Akto Endpoint Shield\akto-endpoint-shield.exe"
$bin2 = Join-Path $pf64 "MCP Endpoint Shield\akto-endpoint-shield.exe"
$systemCfgCandidates = @(
(Join-Path ${env:WINDIR} "Sysnative\config\systemprofile\.akto-endpoint-shield\config\config.env")
(Join-Path $env:SystemRoot "System32\config\systemprofile\.akto-endpoint-shield\config\config.env")
)
$systemCfg = $null
foreach ($candidate in $systemCfgCandidates) {
if (Test-Path -LiteralPath $candidate) { $systemCfg = $candidate; break }
}
if (-not $systemCfg) { $systemCfg = $systemCfgCandidates[0] }
$binPath = $null
if (Test-Path -LiteralPath $bin1) { $binPath = $bin1 }
elseif (Test-Path -LiteralPath $bin2) { $binPath = $bin2 }
if (-not $binPath) {
$sPath = Split-Path $script:MyInvocation.MyCommand.Path -Parent
$fPath = Join-Path $sPath $fileName
if (-not (Test-Path -LiteralPath $fPath)) {
Write-Error "Installer not found: $fPath"
exit 1
}
Write-Output "Running: $fPath $arguments"
$p = Start-Process -FilePath $fPath -ArgumentList $arguments -Wait -PassThru
if ($null -eq $p -or $p.ExitCode -ne 0) {
Write-Error "Installer failed. ExitCode=$($p.ExitCode)"
exit 1
}
$deadline = (Get-Date).AddMinutes(5)
do {
if (Test-Path -LiteralPath $bin1) { $binPath = $bin1; break }
if (Test-Path -LiteralPath $bin2) { $binPath = $bin2; break }
Start-Sleep -Seconds 15
} while ((Get-Date) -lt $deadline)
if (-not $binPath) {
Write-Error "Binary missing after install. Checked: $bin1 ; $bin2"
if (Test-Path "C:\Windows\Temp\akto-endpoint-shield-install.log") {
Get-Content "C:\Windows\Temp\akto-endpoint-shield-install.log" -Tail 30
}
exit 1
}
Write-Output "Installed: $binPath"
foreach ($candidate in $systemCfgCandidates) {
if (Test-Path -LiteralPath $candidate) { $systemCfg = $candidate; break }
}
}
else {
Write-Output "Binary present: $binPath - running config sync"
if (-not (Test-Path -LiteralPath $systemCfg)) {
$sPath = Split-Path $script:MyInvocation.MyCommand.Path -Parent
$fPath = Join-Path $sPath $fileName
if (Test-Path -LiteralPath $fPath) {
Write-Output "SYSTEM config missing - re-running installer"
$p = Start-Process -FilePath $fPath -ArgumentList $arguments -Wait -PassThru
if ($null -eq $p -or $p.ExitCode -ne 0) {
Write-Error "Installer failed. ExitCode=$($p.ExitCode)"
exit 1
}
Start-Sleep -Seconds 30
foreach ($candidate in $systemCfgCandidates) {
if (Test-Path -LiteralPath $candidate) { $systemCfg = $candidate; break }
}
}
}
}
if (-not (Test-Path -LiteralPath $systemCfg)) {
Write-Error "SYSTEM config missing. Checked: $($systemCfgCandidates -join ' ; ')"
exit 1
}
Write-Output "Using SYSTEM config: $systemCfg"
$configContent = Get-Content -LiteralPath $systemCfg -Raw
$configContent = $configContent.TrimEnd()
Get-CimInstance Win32_UserProfile -ErrorAction SilentlyContinue | ForEach-Object {
if ($_.Special -or -not $_.LocalPath) { return }
if ($_.SID -notmatch '^S-1-5-21-') { return }
if (-not (Test-Path -LiteralPath $_.LocalPath)) { return }
$userCfg = Join-Path $_.LocalPath ".akto-endpoint-shield\config\config.env"
$cfgDir = Split-Path -Parent $userCfg
if (-not (Test-Path -LiteralPath $cfgDir)) {
New-Item -ItemType Directory -Path $cfgDir -Force | Out-Null
}
$out = $configContent
if (Test-Path -LiteralPath $userCfg) {
$agentId = Get-Content -LiteralPath $userCfg -ErrorAction SilentlyContinue |
Where-Object { $_ -match '^AGENT_ID=' } | Select-Object -First 1
if ($agentId -and ($out -notlike "*AGENT_ID=*")) {
$out = $out + [Environment]::NewLine + $agentId
}
}
Set-Content -LiteralPath $userCfg -Value $out -Encoding UTF8
Write-Output "Synced config: $userCfg"
}
$taskNames = @("MCPEndpointShieldAgent", "MCPEndpointShieldHTTP", "MCPEndpointShieldDetector")
foreach ($taskName in $taskNames) {
$task = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
if (-not $task) {
Write-Output "Task not found (skipped): $taskName"
continue
}
try {
Stop-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
Start-Sleep -Seconds 3
Start-ScheduledTask -TaskName $taskName -ErrorAction Stop
Write-Output "Restarted: $taskName"
}
catch {
& schtasks.exe /End /TN $taskName 2>$null | Out-Null
Start-Sleep -Seconds 3
& schtasks.exe /Run /TN $taskName 2>$null | Out-Null
Write-Output "Restarted via schtasks: $taskName"
}
}
Write-Output "Success: $binPath (config propagated; tasks restarted)"
exit 0Verify (optional)
Hooks and system proxy
Troubleshooting
Issue
Fix
Uninstall
Related documentation
Get Support
Last updated
