This guide contains everything required to deploy the Liongard Agent in a silent, automated, and duplicate-safe manner using the LGAgentScript PowerShell script.
You can download the script by clicking the following link. Just be sure to input your variables and rename it to"LGAgentScript.ps1" before use:
Scripts are named LGAgentScript_YYYYMMDD to indicate the build date; YYYYMMDD reflects when the script was generated so partners can confirm theyβre using the latest version.
This script supports:
Mass RMM deployment
Optional uninstall + cleanup prior to reinstall
Environment name matching
Machine identity collision prevention
Safe backend record deletion (optional)
π§ What LGAgentScript.ps1 Does
Functionality | Description |
Silent installation | MSI deployment without prompts |
Validates configuration inputs | Prevents empty or placeholder values |
Environment name matching | Matches the Environment parameter with existing environments in Liongard |
Detects MachineGuid collisions | Prevents Agent overwrite scenarios |
Generates override DEVICEGUID | Only when a collision is confirmed |
Optional uninstall prior to install | Removes service, folder, registry keys |
Optional deletion of backend record | Only when the scoring threshold is met |
Transcript logging | Creates a full script execution trace |
Installer logging | Captures MSI installer result |
β Script Configuration in LGAgentScript.ps1
Update this section at the top of the file or map via RMM variables:
To Generate the Token Key(s) & Secret(s), please follow the below steps
Click on your name at the top right corner
Select "Account Settings"
Select "Access Token"
Select "Generate New Token"
Select "Liongard API Token"
This will provide you with #ApiTokenKey & #ApiTokenSecretSelect "Agent Install Token"
This will provide you with #AgentTokenKey & #AgentTokenSecret
π Script Outline
When running the script:
Validates configuration values
Optionally uninstalls any existing Liongard Agent
Attempts to match the provided Environment variable with an existing Liongard environment
Detects MachineGuid conflicts with existing Agents
Generates a DEVICEGUID override if necessary
Calls the MSI installer silently
Evaluates MSI success & logs outcomes
Records execution details in the transcript log
Exits with a clean success or failure code for RMM interpretation
π§― Troubleshooting & Logs
LGAgentScript.ps1 generates two log files every run.
Log | Description | Location |
Script Transcript & Diagnostic Log | Machine identity decisions, uninstall logic, deletion scoring, environment processing |
|
MSI Installer Log | MSI exit code, errors, and silent failure reasoning |
|
If Deployment Fails
π Check the MSI Log:
Path β C:\Liongard\AgentInstall.log
Useful for:
1603 Fatal error
Blocked by a security tool
Incorrect MSI parameters
Missing permissions
π Check the Script Transcript Log:
Path β C:\Liongard\LGAgentScript_<timestamp>.log
Shows:
Matched identities and scoring
Whether the DEVICEGUID override was required
Whether removal was allowed
Why backend deletion was skipped
β Disclaimer
Liongard provides this script as-is and is not responsible for custom modifications or misuse. Always validate configuration values and test in a controlled environment prior to mass deployment to avoid unintended disruptions.

