> For the complete documentation index, see [llms.txt](https://wiki.datadike.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.datadike.com/sonar/deploy-operate/mass-deployment.md).

# Deploy agents at scale

Roll the SONAR agent out to many devices: reusable installers, deployment links in Agents › Deployments, GPO and software distribution, and checking arrivals.

## What this is and when to use it

Every installer the console produces is bound to one client and one site, and works on any number of devices while it is valid. Rolling SONAR out to a whole site is therefore a matter of producing one installer per site and device type, and running it everywhere with the tool you already use — Group Policy, a software distribution or MDM tool, an RMM being replaced, SSH automation.

Two sources of installers:

* **Agents › Install Agent** — a file or command you download once and distribute: the Windows **Dynamic (.exe)** or **PowerShell** script, the Linux script, the macOS command. See the platform pages linked below.
* **Agents › Deployments** — a reusable **download link** per site for Windows. Each time the link is opened, SONAR builds a fresh installer with the current agent version, until the deployment's **Expiry**.

## Before you start

* To manage deployment links, your role has **List Deployments** and **Manage Deployments** in **Admin Center › Roles**. To generate installers in **Install Agent**, it has **Install Agents**. Both only cover the sites your role gives you access to.
* The clients and sites exist. Plan one installer or deployment per site, per device type (**Server** or **Workstation**) and per architecture.
* Antivirus and EDR exclusions are in place before the rollout. See [Endpoint requirements](https://wiki.datadike.com/sonar/deploy-operate/requirements.md#antivirus-and-edr-exclusions).
* Every target network allows outbound 443/tcp to the SONAR API and remote access addresses. See [Network requirements](https://wiki.datadike.com/sonar/deploy-operate/network-requirements.md).
* For installers from **Install Agent**, switch on **Enable token expiration (hours)** with enough hours to cover the whole rollout window. After that the installer stops working and a new one is needed.

## Steps

### Create a deployment link (Windows)

1. Open **Agents › Deployments**. The **Deployments** dialog lists the existing deployments.
2. Click the **+** button (**Create Deployment**). The **Add Deployment** form opens.
3. Choose the **Site**.
4. Choose the **Agent Type**: **Server** or **Workstation**.
5. Set the **Expiry** date and time.
6. Choose the **Architecture**: **64 bit** or **32 bit**.
7. Tick the **Optional Features** the devices should get. They are the same as in **Install Agent** and are described in [Install the agent on Windows](https://wiki.datadike.com/sonar/deploy-operate/install-agent-windows.md#field-reference).
8. Click **Create Deployment**. *The deployment was added successfully* appears, and the new row is added to the list.
9. In the row, under **Download Link**, click **Copy**. *Link copied to clipboard* confirms it.

Opening the link downloads `sonar-<client>-<site>-<type>-<architecture>.exe`, the same Dynamic installer as **Install Agent** produces, which runs silently with `/S`.

### Deploy with a Group Policy startup script (Windows)

A computer startup script runs as Local System, before anyone logs on, which is the context the silent installer expects.

1. Save a script such as this one, with your deployment link, in a share that domain computers can read:

   ```powershell
   if (-not (Get-Service -Name sonarrmm -ErrorAction SilentlyContinue)) {
       $installer = Join-Path $env:TEMP 'sonar-agent.exe'
       Invoke-WebRequest -Uri '<deployment link>' -OutFile $installer -UseBasicParsing
       Start-Process -FilePath $installer -ArgumentList '/S' -Wait
       Remove-Item $installer -Force
   }
   ```

   The service check makes the script do nothing on devices that already have the agent. Instead of downloading from a link, the script can equally run a Dynamic (.exe) installer copied to the share.
2. In **Group Policy Management**, create or edit a GPO linked to the organisational unit of the target computers.
3. Under **Computer Configuration › Policies › Windows Settings › Scripts (Startup/Shutdown)**, add the script as a **Startup** PowerShell script.
4. Restart the target computers, or wait for their next restart.

### Deploy with a software distribution or MDM tool (Windows)

Package the Dynamic (.exe) installer from **Install Agent** or from a deployment link as an application:

| Setting           | Value                                                                           |
| ----------------- | ------------------------------------------------------------------------------- |
| Install command   | `sonar-<client>-<site>-<type>-<architecture>.exe /S`                            |
| Uninstall command | `"C:\Program Files\Sonar\uninstall.exe" /S`                                     |
| Run as            | System                                                                          |
| Detection         | Service `sonarrmm` exists, or file `C:\Program Files\Sonar\sonarrmm.exe` exists |

The PowerShell script from **Install Agent** can be distributed the same way; it checks for the `sonarrmm` service itself and exits if the agent is already there.

### Deploy on Linux and macOS

* **Linux:** run the script from **Install Agent** as root on each machine through your automation — SSH, configuration management, a jump host loop: `sudo bash ./sonar-<client>-<site>-<type>.sh`. The script removes any previous agent before installing. See [Install the agent on Linux](https://wiki.datadike.com/sonar/deploy-operate/install-agent-linux.md).
* **macOS:** run the command from **Install Agent** as root through your MDM or remote shell. Where operators need protected user folders from the remote access window, grant **Full Disk Access** through an MDM privacy profile. See [Install the agent on macOS](https://wiki.datadike.com/sonar/deploy-operate/install-agent-macos.md).

## What you should see

Devices appear in **Dashboard › Sysadmin** under their client and site as each installation completes, with **Agent Status** **Online**. On the **Clients overview**, the card of the client shows the growing device count.

## How to verify it worked

1. Open **Dashboard › Sysadmin** and click the client card.
2. Sort the device list by **First Seen**, newest first: the devices of the rollout are at the top, with the date they registered.
3. Open **Filters** and, under **Availability**, pick **Online**; under **Device Type**, pick **Servers** or **Workstations** to match the batch. Compare the count with the list of devices you targeted.
4. For devices on your list that are missing, check the deployment tool's own result on those devices, then [Troubleshoot agents](https://wiki.datadike.com/sonar/deploy-operate/troubleshooting.md).
5. In **Reports & Audits › Audits**, each registration is an **Agent Install** entry with the host name, which gives the order and time of arrival.

## Common errors

| Symptom                                                                        | Cause                                                                                                                                                                    | Fix                                                                                               |
| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------- |
| *expire date is invalid* when creating a deployment                            | **Expiry** is empty or incomplete                                                                                                                                        | Fill in both the date and the time                                                                |
| Installers stop with *Installer token has expired. Please generate a new one.* | The deployment passed its **Expiry**, the deployment was deleted, or the **Install Agent** installer passed its token expiration                                         | Create a new deployment or installer and update the link or package in your tool                  |
| Installers saved before the rollout stop with *Old installer detected*         | The SONAR agent version changed after the file was generated                                                                                                             | Generate the file again, or use a deployment link, which always builds the current version        |
| The silent install reports success but the device never appears                | The device already had an agent or what is left of one; the installer prints *Existing installation found and must be removed before attempting to reinstall.* and exits | Run `"C:\Program Files\Sonar\uninstall.exe" /S` on the device, then install again                 |
| An installation run inside a logged-on user's session does not finish          | The agent's final message box is waiting for **OK**                                                                                                                      | Run the installer as Local System, or use the PowerShell script, which runs without message boxes |
| Devices arrive under the wrong site                                            | The installer or link of another site was used                                                                                                                           | Move the devices to the right site, and check which file each package uses                        |
| The **+** button, **Copy** or **Delete** does nothing                          | Your role lacks **Manage Deployments**                                                                                                                                   | Ask for the permission                                                                            |

## Field reference

### Add Deployment

| Field                 | What it does                                                                                                                                        | Accepted values                               | Default                |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- | ---------------------- |
| **Site**              | Site the devices are registered under                                                                                                               | Sites your role can access, grouped by client | First site in the list |
| **Agent Type**        | Records the devices as servers or workstations                                                                                                      | **Server**, **Workstation**                   | **Server**             |
| **Expiry**            | Date and time after which installers from this link stop working                                                                                    | A date and time                               | 30 days from now       |
| **Architecture**      | Windows architecture of the installer                                                                                                               | **64 bit**, **32 bit**                        | **64 bit**             |
| **Optional Features** | Same features as in **Install Agent**: **Sessions**, **Geolocation**, **Remote access**, **Ping**, and **Disable sleep/hibernate** for workstations | Ticked or not                                 | None ticked            |

### Deployments list

| Column            | What it shows                                      |
| ----------------- | -------------------------------------------------- |
| **Client**        | Client of the deployment's site                    |
| **Site**          | Site the devices are registered under              |
| **Type**          | **server** or **workstation**                      |
| **Arch**          | `amd64` (64 bit) or `386` (32 bit)                 |
| **Expiry**        | When the link stops producing working installers   |
| **Created**       | When the deployment was created                    |
| **Flags**         | **View Flags**; hover to see the optional features |
| **Download Link** | **Copy** puts the link on the clipboard            |

Right-click a row and choose **Delete** to remove a deployment, then confirm **Delete deployment?**. Installers already downloaded from that link stop working as well.

## Related pages

* [Install the agent on Windows](https://wiki.datadike.com/sonar/deploy-operate/install-agent-windows.md)
* [Install the agent on Linux](https://wiki.datadike.com/sonar/deploy-operate/install-agent-linux.md)
* [Install the agent on macOS](https://wiki.datadike.com/sonar/deploy-operate/install-agent-macos.md)
* [The device list](https://wiki.datadike.com/sonar/administration/devices/device-list.md)
* [Troubleshoot agents](https://wiki.datadike.com/sonar/deploy-operate/troubleshooting.md)
