macOS scripts for Lansweeper Agent management, force rescan, remote execution, and 3rd-party app version checking.
| Script | Purpose | Run As |
|---|---|---|
π οΈ force-rescan-lsagent.sh |
Interactive LsAgent rescan with settings editor | sudo on Mac |
π remote-exec-template.sh |
GoTo Resolve remote execution template | GoTo Resolve / sudo |
π check-app-versions.sh |
Scan installed apps, check for updates via Homebrew Cask API | Any user / sudo |
These scripts complement the pa-lsagent Power Automate flow:
ββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
β π₯οΈ Mac Endpoints β β βοΈ Lansweeper Cloud β
β ββββββββΆβ (scans assets + software)β
β LsAgent installed β scan β β
β check-app-versions β βββββββββββ¬ββββββββββββββββββ
β force-rescan β β GraphQL API
ββββββββββββββββββββββββ βΌ
βββββββββββββββββββββββββββββ
β β‘ PA-LsAgent Flow β
β (Power Automate) β
β β
β tblPCs / tblMonitors β
β tblPeripherals β
β tblNetwork β
β tblMacSoftware β NEW β
βββββββββββ¬ββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββ
β π SharePoint Excel β
β Asset Tracking Workbook β
βββββββββββββββββββββββββββββ
# 1. Clone the repo
git clone https://github.com/GreenHornet-Dev/lsagent-mac.git
cd lsagent-mac
# 2. Make scripts executable
chmod +x *.sh
# 3. Force rescan (interactive)
sudo ./force-rescan-lsagent.sh
# 4. Check app versions (no sudo needed)
./check-app-versions.sh
Open Terminal on your Mac and paste any of these blocks.
# Clone repo and make all scripts executable
git clone https://github.com/GreenHornet-Dev/lsagent-mac.git
cd lsagent-mac && chmod +x *.sh
cd ~/lsagent-mac && sudo ./force-rescan-lsagent.sh
Stops agent β backs up config β lets you edit settings β clears cache β restarts agent
cd ~/lsagent-mac && ./check-app-versions.sh
Scans all installed apps β checks Homebrew Cask API for latest β color-coded report + JSON output
cd ~/lsagent-mac && sudo ./remote-exec-template.sh
Runs the GoTo Resolve template locally for testing before deploying remotely
If you just need the version checker on a Mac without cloning the full repo:
curl -fsSL https://raw.githubusercontent.com/GreenHornet-Dev/lsagent-mac/main/check-app-versions.sh | bash
Or download first, inspect, then run (recommended):
curl -fsSL https://raw.githubusercontent.com/GreenHornet-Dev/lsagent-mac/main/check-app-versions.sh -o /tmp/check-app-versions.sh
cat /tmp/check-app-versions.sh # review the script
chmod +x /tmp/check-app-versions.sh && /tmp/check-app-versions.sh
For the force-rescan tool (requires sudo):
curl -fsSL https://raw.githubusercontent.com/GreenHornet-Dev/lsagent-mac/main/force-rescan-lsagent.sh -o /tmp/force-rescan-lsagent.sh
chmod +x /tmp/force-rescan-lsagent.sh && sudo /tmp/force-rescan-lsagent.sh
cd ~/lsagent-mac && git pull origin main
/Library/Application Support/LanSweeper/LsAgent/lsagent.ini
/Library/LaunchDaemons/com.lansweeper.lsagent.plist
force-rescan-lsagent.shInteractive tool for hands-on LsAgent rescan. Run this when youβre at the Mac or SSHβd in.
| Step | Action |
|---|---|
| 1οΈβ£ | Checks for root/sudo access |
| 2οΈβ£ | Stops LsAgent (graceful β force kill if needed) |
| 3οΈβ£ | Creates timestamped backup of lsagent.ini |
| 4οΈβ£ | Displays ALL settings β color-coded π’π΄ |
| 5οΈβ£ | Interactive editor β change any setting by number |
| 6οΈβ£ | Auto-clears Field7 and Field8 (scan cache) |
| 7οΈβ£ | Restarts LsAgent and confirms itβs running |
| 8οΈβ£ | Prints summary with agent status check |
[1] Server = lansweeper.yourdomain.com
[2] Port = 9524
[3] ScanInterval = 86400
[4] Field7 = a3f8c2... β WILL BE CLEARED π΄
[5] Field8 = 1711234... β WILL BE CLEARED π΄
ββββββββββββββββββββββββββββββββββββββββ
Options:
[number] - Edit a setting by its number
[a] - Show all settings again
[c] - Continue with rescan
[q] - Quit without restarting
set -euo pipefail for safer executionpkill -9 β error with manual commandsed escaping for special characters in valueslsagent.ini if not found at default pathremote-exec-template.shSilent, unattended execution via GoTo Resolve Remote Execution. Copy and customize for any remote macOS task.
remote-exec-template.shmacOS0 = β
SUCCESSchmod +x remote-exec-template.sh
sudo ./remote-exec-template.sh
| Function | What It Does |
|---|---|
setup_logging() |
Creates log directory, rotates old logs (30+ days) |
log() |
Timestamped logging β color in terminal, plain text in GoTo |
preflight() |
Logs hostname, macOS version, arch, user, connectivity |
stop_service() |
Graceful unload β force kill β error reporting |
start_service() |
Load plist β verify process β delayed retry |
backup_file() |
Timestamped .bak copy before any edits |
edit_ini_field() |
Safely set or clear any key=value with sed escaping |
display_config() |
Dump full config to log with line numbers |
report_result() |
SUCCESS/FAILURE exit code for GoTo dashboard |
cp remote-exec-template.sh my-new-task.sh
Edit the header:
TASK_NAME="My Custom Task"
TASK_VERSION="1.0"
Replace only main() β all helpers stay the same.
set -uo pipefail for safer execution/tmp) if /var/log is not writablestop_service() (graceful β force β error)start_service() (waits extra 5s if process slow)edit_ini_field()/var/log/goto-resolve-scripts/<TIMESTAMP>_<TASK_NAME>.log
check-app-versions.shScans all installed 3rd-party Mac apps and checks for available updates using the Homebrew Cask API.
/Applications and ~/ApplicationsInfo.plisthttps://formulae.brew.sh/api/cask/<token>.json# No sudo needed for basic scan
chmod +x check-app-versions.sh
./check-app-versions.sh
APP NAME INSTALLED LATEST STATUS
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Google Chrome 131.0.6778.86 132.0.6834.57 π΄ UPDATE
Slack 4.39.95 4.39.95 π’ OK
Visual Studio Code 1.96.0 1.96.0 π’ OK
Zoom 6.3.5 6.3.6 π΄ UPDATE
Firefox 133.0 133.0 π’ OK
Docker 4.37.1 4.37.2 π΄ UPDATE
βββββββββββββββββββββββββββββββββββββββββββββββββββ
π Summary β MACBOOK-PRO.local
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Total scanned: 42
π’ Up to date: 35
π΄ Needs update: 5
π΅ Newer than repo: 0
βͺ Unknown/N/A: 2
β οΈ 5 app(s) need updating!
Outdated apps:
β’ Google Chrome 131.0.6778.86 β 132.0.6834.57
β’ Zoom 6.3.5 β 6.3.6
β’ Docker 4.37.1 β 4.37.2
...
The script writes a JSON file to /tmp/lsagent-mac/ that the pa-lsagent Power Automate flow can consume:
{
"hostname": "MACBOOK-PRO.local",
"macosVersion": "14.5",
"scanDate": "2026-03-24T05:00:00Z",
"scriptVersion": "1.0",
"summary": {
"total": 42,
"current": 35,
"outdated": 5,
"newer": 0,
"unknown": 2
},
"apps": [
{
"appName": "Google Chrome",
"bundleId": "com.google.Chrome",
"installedVersion": "131.0.6778.86",
"latestVersion": "132.0.6834.57",
"caskToken": "google-chrome",
"status": "outdated",
"hostname": "MACBOOK-PRO.local",
"scanDate": "2026-03-24T05:00:00Z"
}
]
}
The JSON output is designed to match a tblMacSoftware Excel table in the pa-lsagent spreadsheet:
| Column | JSON Key | Description |
|---|---|---|
| Hostname | hostname |
Mac computer name |
| AppName | appName |
Application name |
| BundleID | bundleId |
macOS bundle identifier |
| InstalledVersion | installedVersion |
Currently installed version |
| LatestVersion | latestVersion |
Latest available from Homebrew |
| CaskToken | caskToken |
Homebrew Cask identifier |
| Status | status |
outdated / current / newer / unknown |
| ScanDate | scanDate |
When the check ran (UTC) |
https://formulae.brew.sh/api/cask/<token>.jsonsort -V (handles semver correctly)Edit the CASK_MAP array at the top of the script:
CASK_MAP=(
# Your custom mappings
["My Internal App"]="my-internal-cask"
["Company Tool"]="company-tool"
...
)
Or use the version-check-apps.json from the pa-lsagent repo for centralized config.
lsagent.ini Field Reference| Field | Purpose | Action |
|---|---|---|
Server |
Lansweeper server hostname or IP | βοΈ Verify/correct if agent isnβt reporting |
Port |
Communication port (default 9524) |
βοΈ Match your server config |
Field7 |
Last scan timestamp cache | ποΈ Clear to force fresh scan |
Field8 |
Scan result/status cache | ποΈ Clear to force fresh scan |
| Other fields | Various agent state values | βοΈ Edit only if directed by Lansweeper support |
π‘ Tip: View the ini manually to confirm your exact field names:
sudo cat "/Library/Application Support/LanSweeper/LsAgent/lsagent.ini"
# Force kill by process name
sudo pkill -9 -f lsagent
# Confirm
pgrep -f lsagent && echo "Still running" || echo "Stopped"
lsagent.ini not found# Search for it
sudo find / -name "lsagent.ini" 2>/dev/null
Update INI_PATH at the top of the script to match.
# Manually load the plist
sudo launchctl load /Library/LaunchDaemons/com.lansweeper.lsagent.plist
# Check system logs
log show --predicate 'process == "lsagent"' --last 10m
Server= points to the correct server9524 is open between Mac and server# List backups
ls "/Library/Application Support/LanSweeper/LsAgent/"*.bak.*
# Restore most recent
sudo cp "/Library/Application Support/LanSweeper/LsAgent/lsagent.ini.bak.YYYYMMDDHHMMSS" \
"/Library/Application Support/LanSweeper/LsAgent/lsagent.ini"
The app doesnβt have a matching Homebrew Cask. Add a custom mapping:
# In the CASK_MAP array at the top of check-app-versions.sh
["Your App Name"]="homebrew-cask-token"
Find the cask token at formulae.brew.sh/cask.
| File | Version | Description |
|---|---|---|
force-rescan-lsagent.sh |
v1.1 | Interactive LsAgent rescan + settings editor |
remote-exec-template.sh |
v1.1 | GoTo Resolve remote execution template |
check-app-versions.sh |
v1.0 | Mac app version checker (terminal + JSON) |
README.md |
β | This documentation |
| Repo | Description |
|---|---|
| pa-lsagent | Power Automate flow β syncs Lansweeper data to SharePoint Excel |
| green-tools | Windows PowerShell toolkit β system updates, app scanning |
| little-helper | Java console tool β WinGet automation, deployment checklists |
launchctl, PlistBuddy, BSD sed, and macOS pathsBuilt by GreenHornet-Dev / Custom Design Systems π’