Skip to main content

Windows Agent Mass Deployment Guide

Deploy the Liongard agent via RMM. Mass deployment of the Liongard Agent. Reinstalling the Liongad Agent.

Updated this week

Liongard Agent Silent Installation Using LGAgentScript.ps1

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:

This script supports:

  • Mass RMM deployment

  • Optional uninstall + cleanup prior to reinstall

  • 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

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:

$InstancePrefix = 'us?'
$ApiTokenKey = 'YOUR_API_TOKEN_KEY'
$ApiTokenSecret = 'YOUR_API_TOKEN_SECRET'
$AgentTokenKey = 'YOUR_AGENT_INSTALL_KEY'
$AgentTokenSecret = 'YOUR_AGENT_INSTALL_SECRET'
$Environment = 'ENVIRONMENT NAME'
$EnablePreUninstall = $true
$IncludeEnvironmentValue = $true
$RemoveAgentFromPlatform = $false
$MinimumRemoteDeletionScore = 50

πŸ›  RMM Deployment Instructions

When executed without an interactive session, LGAgentScript.ps1 enters Headless Mode and reads variables from its configuration or from environment variables passed by your RMM.


1️⃣ Datto RMM

➑ Automation β†’ Components β†’ New Component

Field

Value

Category

Script β†’ PowerShell

Script

Paste LGAgentScript.ps1

➑ Variables to Map

Datto Variable

Script Variable

InstancePrefix

$InstancePrefix

ApiTokenKey

$ApiTokenKey

ApiTokenSecret

$ApiTokenSecret

AgentTokenKey

$AgentTokenKey

AgentTokenSecret

$AgentTokenSecret

Environment

$Environment

➑ Execution

powershell.exe -ExecutionPolicy Bypass -File "LGAgentScript.ps1"

2️⃣ ConnectWise Automate (CWA)

➑ Add Script β†’ Insert "Execute Script β†’ PowerShell"

➑ Parameter section example:

Set-Variable InstancePrefix "us?"
Set-Variable ApiTokenKey "YOUR_API_KEY"
Set-Variable ApiTokenSecret "YOUR_API_SECRET"
Set-Variable AgentTokenKey "YOUR_AGENT_KEY"
Set-Variable AgentTokenSecret "YOUR_AGENT_SECRET"
Set-Variable Environment "%ClientName%"

βœ” %ClientName% auto-inserts the environment name.


3️⃣ NinjaOne

➑ Configuration β†’ Scripting β†’ Add Script

➑ Parameters Example:

InstancePrefix = us?
ApiTokenKey = YOUR_KEY
ApiTokenSecret = YOUR_SECRET
AgentTokenKey = YOUR_AGENT_KEY
AgentTokenSecret = YOUR_AGENT_SECRET
Environment = $msg.organization_name

4️⃣ Kaseya VSA

➑ Upload script to:

#vAgentConfiguration.agentTempDir#\LGAgentScript.ps1

➑ Execute:

powershell.exe -ExecutionPolicy Bypass -File "#vAgentConfiguration.agentTempDir#\LGAgentScript.ps1"

🧯 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

C:\Liongard\LGAgentScript_<timestamp>.log

MSI Installer Log

MSI exit code, errors, silent failure reasoning

C:\Liongard\AgentInstall.log


If Deployment Fails

πŸ“Œ Check RMM Output

The script returns readable console messages.

πŸ“Œ Check the MSI Log:

Path β†’ C:\Liongard\AgentInstall.log

Useful for:

  • 1603 Fatal error

  • Blocked by security tool

  • Incorrect MSI parameters

  • Missing permissions

πŸ“Œ Check the Script Transcript Log:

Path β†’ C:\Liongard\LGAgentScript_<timestamp>.log

Shows:

  • Matched identities and scoring

  • Whether DEVICEGUID override was required

  • Whether removal was allowed

  • Why backend deletion was skipped


πŸ“„ Script Outline

When running, the script:

1️⃣ Validates configuration values
2️⃣ Optionally uninstalls any existing Liongard Agent
3️⃣ Detects MachineGuid conflicts with existing agents
4️⃣ Generates a DEVICEGUID override if necessary
5️⃣ Calls MSI installer silently
6️⃣ Evaluates MSI success & logs outcomes
7️⃣ Records execution details in transcript log
8️⃣ Exits with a clean success or failure code for RMM interpretation


⚠ 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.

Attachment icon
Did this answer your question?