Community-shared tools & configurations for AppSense Environment Manager, Application Manager and Performance Manager

Automating AppSense Agent Upgrades with a PowerShell Wrapper

AppSense agents underpin the software delivery, licensing, and machine-context behaviour that Australian organisations rely on, yet the agent itself is often the least consistently patched component in an estate. Windows workstations and servers drift across several agent versions because each team upgrades in its own time, and every new release carries fixes for defects that only surface in production. Support calls about failed upgrades, stale RunOnce entries, or agent services that refuse to start then arrive weeks after the change window has closed.

This is where a PowerShell wrapper earns its keep. Rather than asking a technician to run an installer and remember a set of silent switches, the wrapper packages those steps into a script that checks the installed agent version, compares it against a target, invokes the vendor package quietly, captures the exit code, and writes a timestamped log. The same file can be triggered by a scheduled task, a Group Policy preference, a Configuration Manager package, or a third-party tool such as PDQ Deploy, so one script can drive upgrades across an office in Melbourne and a site outside Kalgoorlie with identical behaviour.

Treating agent upgrades as repeatable code shifts the conversation from who remembered to patch this machine to what is the current version across the fleet and what failed. It also gives auditors and risk owners something a manual process rarely produces: evidence. For organisations working under the Privacy Act 1988 and the guidance of the Office of the Australian Information Commissioner, a defensible record of what ran, when it ran, and what changed carries real weight.

Why agent version drift slows Australian estates

The pain is amplified by geography. Many Australian businesses run mature Configuration Manager or Intune estates in metropolitan offices while regional branches, research stations, and mine camps rely on whatever tool was installed years earlier. Where there is no central platform, upgrades happen opportunistically, and version reporting is a manual exercise conducted by email request.

Timing compounds the problem. United States Patch Tuesday falls mid-morning on Wednesday in Melbourne and Sydney, which compresses the window for testing and deployment. Daylight saving shifts in October and April also move local execution times, so a script scheduled for 21:00 can land at 20:00 or 22:00 for several weeks and behave differently across the eastern states.

A wrapper removes the variability without adding licensing. The upgrade logic lives in one reviewed file, the parameters are explicit, and the outcome of every run is written to disk. Technicians stop re-typing installers and start reading logs.

Designing the PowerShell wrapper

A workable wrapper accepts parameters instead of hard-coded paths, creates its own log directory, starts a transcript, runs the vendor installer with silent arguments, records the exit code, and stops the transcript even when the installer fails. Wrapping the whole block in error handling keeps a failed upgrade from leaving a half-written log behind.

param(
    [string]$Package = "\\files01\packages\AppSenseAgent\setup.exe",
    [string]$LogPath = "$env:ProgramData\AppSense\UpgradeLogs"
)

$ErrorActionPreference = 'Stop'
New-Item -Path $LogPath -ItemType Directory -Force | Out-Null
$stamp = (Get-Date).ToString('yyyyMMdd-HHmmss')
$log = Join-Path $LogPath "upgrade-$stamp.log"

Start-Transcript -Path $log -Append
Write-Host "Starting agent upgrade using $Package"
$proc = Start-Process -FilePath $Package `
    -ArgumentList '/qn', '/norestart' -Wait -PassThru
Write-Host "Installer exit code: $($proc.ExitCode)"
Stop-Transcript

Two refinements make the difference between a script that runs and a script you trust. First, detection logic should read the currently installed version from the registry or product files and exit cleanly when the target version is already present, so a repeat run is harmless. Second, the script should verify the agent service state after the installer returns and flag anything that needs a restart rather than silently reporting success.

Self-elevation, prerequisite checks, and download handling belong in the wrapper too. Confirm the supported operating system versions and any runtime dependencies before starting, cache the package locally so a flaky link does not abort an install halfway through, and record every stage so a support engineer can reconstruct the failure from the log alone.

Scheduling and distribution across the estate

Distribution decisions come down to bandwidth and management maturity. Metro offices with an NBN connection can pull packages from an internal file server or a cloud repository, while sites on satellite, fixed wireless, or regional fixed-line services benefit from copying the installer to each remote server once and deploying from that local copy. Scripted upgrades also cut the operational cost of running them across a few hundred endpoints without a management console.

Timetables matter as much as transport. Scheduling wrapper runs outside business hours avoids interrupting staff in Brisbane, Adelaide, or Perth, and a small pilot group should always precede a full deployment ring. End-of-financial-year change freezes, common across government and enterprise environments after 30 June, are another reason to build a repeatable, evidence-producing process rather than rely on ad hoc technician visits.

Peer knowledge saves days of testing. Threads in the AppSense Exchange communities regularly expose silent switch combinations, service restart quirks, and version-specific problems that would otherwise be rediscovered on your own endpoints. Community advisors and fellow members also flag which package types behave well with scripted execution.

Approach Trigger and scale Logging and evidence Failure handling Best fit
Manual installer by desktop support One machine at a time Notes held in a ticketing system Technician judgement, slow rollback Pilot estates and lab machines
Wrapper run by scheduled task Hundreds of endpoints, no extra licence Timestamped transcript per endpoint Exit codes parsed, retry logic, staged rings Lightly managed and remote sites
Wrapper packaged for Intune or Configuration Manager Central policy and reporting Console history plus wrapper log Native remediation and pilot rings Metro offices with modern tooling
Chocolatey or PDQ Deploy calling the wrapper Fast recurring execution Wrapper log plus tool history Straightforward retry, limited context Smaller fleets needing quick runs

Detection, silent switches, and failure handling

Vendor packages arrive in different shapes, and the wrapper needs to handle both. MSI-based installers usually accept /qn or /quiet with a REBOOT=ReallySuppress property, while EXE installers tend to use /S, /silent, or vendor-specific flags. Guessing these switches is the most common cause of an upgrade that appears to work but leaves the old version in place, so confirm them against the release documentation before the wrapper enters production.

Exit codes are the fastest diagnostic signal available. A return of zero confirms a clean install, 3010 signals a required reboot, and 1603 points to a fatal installation error that usually belongs in a log review rather than a retry loop. Embedding a small mapping of exit codes to actions keeps the response consistent: log and exit, log and schedule a reboot, or raise an alert for a technician.

Verification after the install completes closes the loop. Query the service status, read back the installed version, and compare it against the target, then write that result to the log. For regulated environments, keep logs free of unnecessary personal information, restrict access to the log directory, and align retention with state records obligations such as the Public Records Act Victoria and its equivalents elsewhere.

First logon repairs and controlled RunOnce handling

Agent upgrades interact with the first sign-in in ways that are easy to miss. Tasks queued as RunOnce entries during deployment can fire before the new agent is fully ready, leaving applications uninstalled, printers missing, or drive mappings absent, and the resulting call often blames the upgrade rather than the ordering of events.

Controlling those entries is where AppSense configuration knowledge pays dividends. Community write-ups such as controlling RunOnce entries show how the platform can govern first logon tasks so they execute in a controlled order instead of racing the agent.

The wrapper can extend that control. A post-upgrade sweep can list pending RunOnce keys, remove entries already completed by the new agent, and re-queue anything that failed. Running that sweep on a scheduled task after the first sign-in turns a fragile race into a repeatable sequence, and it gives you a place to record the final state of the machine for reporting.

Practical recommendations for Australian deployments

Risk owners in government and critical infrastructure often map agent patching directly to the Australian Signals Directorate Essential Eight, where secure configuration and vulnerability management carry explicit obligations. A wrapper supports that mapping by producing consistent, dated evidence of which machines were upgraded, and by allowing exceptions to be documented rather than hidden.

Several practices keep a wrapper dependable across regions and business days. Building these into the script and its deployment plan pays dividends well beyond the initial rollout.

Alignment with broader governance makes the activity easier to defend. Internal audit teams typically want to see a change record, an approval, a test result, and a deployment list, and a wrapper generates all four as a by-product of normal operation. Documenting the script in the resource hub with version notes and known issues also gives new technicians a usable starting point instead of an empty search.

Start with the community resource library and discussion forums to find an existing wrapper pattern or a configuration that matches your agent version, then adapt it to your own silent switches and logging paths. Share the finished script back through the same channels so the next team inherits a tested file rather than starting from scratch, and open a thread when you hit behaviour specific to your estate. The result is an estate where agent versions are known, upgrades are unattended, and every change leaves a trail that satisfies both engineers and auditors.