Austin
11/13/2026, 5:35 PM# Author: Austin Parker <austin@packet415.com>
#
# Re-points the orbit service symlink at the host's configured channel and restarts the service.
#
# Context: bin\orbit\orbit.exe is a symlink that the Windows service ImagePath targets.
# On affected hosts it is stuck pointing at an old version even though the configured
# version was downloaded successfully and is present under bin\orbit\windows\<channel>\.
#
# The desired channel is read from server-overrides.json (same source orbit itself uses)
# rather than hardcoded, so this is safe across hosts pinned to different versions.
$ErrorActionPreference = "Stop"
$ServiceName = "Fleet osquery"
$OrbitRoot = "C:\Program Files\Orbit"
$Link = Join-Path $OrbitRoot "bin\orbit\orbit.exe"
$OverridesPath = Join-Path $OrbitRoot "server-overrides.json"
$service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
if (-not $service) {
Write-Error "Service '$ServiceName' not found."
exit 1
}
# Resolve the channel this host is actually supposed to run.
# This MUST come from the host's own config. There is deliberately no default: re-pointing
# a host at a version it was never assigned is worse than leaving it on the old one, so if
# the intended channel cannot be established the script aborts without touching anything.
if (-not (Test-Path $OverridesPath)) {
Write-Error "Not found: $OverridesPath. Cannot determine intended orbit channel; aborting without changes."
exit 1
}
try {
$channel = (Get-Content $OverridesPath -Raw | ConvertFrom-Json).'orbit-channel'
} catch {
Write-Error "Could not parse $OverridesPath : $($_.Exception.Message). Aborting without changes."
exit 1
}
if ([string]::IsNullOrWhiteSpace($channel)) {
Write-Error "No 'orbit-channel' key in $OverridesPath. Aborting without changes."
exit 1
}
$Target = Join-Path $OrbitRoot "bin\orbit\windows\$channel\orbit.exe"
# Refuse to proceed unless the destination binary is really there and non-empty.
$targetItem = Get-Item $Target -Force -ErrorAction SilentlyContinue
if (-not $targetItem -or $targetItem.Length -eq 0) {
Write-Error "Target binary for channel '$channel' missing or zero-length: $Target"
exit 1
}
$linkItem = Get-Item $Link -Force -ErrorAction SilentlyContinue
if ($linkItem -and $linkItem.LinkType -ne "SymbolicLink") {
Write-Error "$Link is not a symlink (LinkType=$($linkItem.LinkType)). Aborting rather than replacing a real binary."
exit 1
}
Write-Output "Channel: $channel"
Write-Output "Current target: $($linkItem.Target)"
Write-Output "Desired target: $Target"
# Nothing to fix -- leave the service alone. A healthy host should not take an agent
# restart just for being audited.
if ($linkItem -and $linkItem.Target -eq $Target) {
Write-Output "NO CHANGE - symlink already points at channel '$channel'. Service not touched."
exit 0
}
Stop-Service -Name $ServiceName -Force
# Wait for the service to fully stop so the old binary is no longer mapped.
(Get-Service -Name $ServiceName).WaitForStatus("Stopped", "00:01:00")
if ($linkItem) {
# Removes the link itself, not the file it points to.
Remove-Item -Path $Link -Force
}
New-Item -ItemType SymbolicLink -Path $Link -Target $Target | Out-Null
Write-Output "Symlink re-pointed to channel '$channel'."
Start-Service -Name $ServiceName
(Get-Service -Name $ServiceName).WaitForStatus("Running", "00:01:00")
Write-Output "Service restarted. Verify the next 'orbit version:' line in the orbit log matches '$channel'."