- New "mode" setting: "netbox" (default, unchanged), "listen" (no NetBox access needed; the inventory is served on a TCP port for the NetBox Synchronizer desktop app) or "both" - Listen protocol v1: HMAC-SHA256 signed requests with nonce and timestamp, AES-256-GCM encrypted inventory, optional allowed_networks; the inventory has the shape of the desktop app's WinRM scan - New options --serve, --print and --version - install.ps1 sets up the listener task (at startup, restarted on failure) and the firewall rule for listen mode, removes what a changed mode no longer needs and stays idempotent - New gpo-startup.ps1 for Group Policy startup scripts: installs or updates from a share only when agent.exe or config.json changed - README, messages and scripts in English Co-Authored-By: Claude Opus 5.5 <[email protected]>
17 lines
1.1 KiB
PowerShell
17 lines
1.1 KiB
PowerShell
param([string]$InstallDirectory = "$env:ProgramFiles\NetBox Windows Agent")
|
|
$ErrorActionPreference = 'Stop'
|
|
Unregister-ScheduledTask -TaskName 'NetBox Windows Agent' -Confirm:$false -ErrorAction SilentlyContinue
|
|
Stop-ScheduledTask -TaskName 'NetBox Windows Agent Listener' -ErrorAction SilentlyContinue
|
|
Unregister-ScheduledTask -TaskName 'NetBox Windows Agent Listener' -Confirm:$false -ErrorAction SilentlyContinue
|
|
Remove-NetFirewallRule -Name 'NetBoxWindowsAgent' -ErrorAction SilentlyContinue
|
|
if (Test-Path -LiteralPath $InstallDirectory) {
|
|
$resolved = (Resolve-Path -LiteralPath $InstallDirectory).Path
|
|
$programFiles = (Resolve-Path -LiteralPath $env:ProgramFiles).Path
|
|
if (-not $resolved.StartsWith($programFiles + '\', [StringComparison]::OrdinalIgnoreCase)) { throw "Unsafe target: $resolved" }
|
|
Get-Process -Name agent -ErrorAction SilentlyContinue |
|
|
Where-Object { $_.Path -and $_.Path.StartsWith($resolved, [StringComparison]::OrdinalIgnoreCase) } |
|
|
Stop-Process -Force -ErrorAction SilentlyContinue
|
|
Start-Sleep -Milliseconds 500
|
|
Remove-Item -LiteralPath $resolved -Recurse -Force
|
|
}
|