# Nightfall macOS Agent Deployment: Mosyle MDM

## Prerequisites

Before you begin, ensure you have:

* Mosyle Business or Mosyle Manager with admin access
* Nightfall **API Key** and **Company ID** - available at `app.nightfall.ai/endpoint` under **Agent Configuration**
* Download the bundle:
  * Script: `mdm_pre_installation_script.sh`
  * Profile: `NightfallAI_Profile_with_Browser_Extensions.mobileconfig`
  * Agent: `nightfall-ai-agent-signed.pkg`
* A target device group scoped to the macOS devices you want to monitor
* (Optional) If the ability to upload a .PKG to Mosyle is not available, make sure the .PKG file is stored/hosted somewhere.

***

## Step 1: Connect Mosyle to Nightfall

1. Log in to `app.nightfall.ai` and navigate to **Settings → MDM Profile**.
2. Select **Mosyle** from the list of supported MDM providers.
3. Follow the OAuth prompts to grant Nightfall read-only access to your Mosyle device inventory and user identity data. This allows Nightfall to map usernames to devices automatically.

***

## Step 2: Deploy the Script

1. Unpack the zip file provided and locate the `mdm_pre_installation_script.sh` file in the `mdm_scripts` folder.
2. On Mosyle, navigate to **Management → Custom Commands**.
3. Paste the content of `mdm_pre_installation_script.sh` into the script editor.
4. Target the command to desired devices group
5. Click **Save**.
6. Run immediately.

## Step 3: **Deploy the Profile**

1. Unpack the zip file provided and locate the `NightfallAI_Profile.mobileconfig` file in the `Profiles` folder.
2. Navigate to Management **→** **Configuration Profiles**.
3. Click the **Upload** button and upload `NightfallAI_Profile.mobileconfig`.
4. Configure the settings for your configuration profile.
5. In the **Scope** tab, add the target devices or device groups to which this profile should be deployed.
6. Click **Save**.

Once assigned, the profile will be automatically deployed to target machines.

## **Step 4: Deploy the Agent (.PKG)**

1. On Mosyle, navigate to **Management → Install PKG → CDN**.
2. Upload the `nightfall-ai-agent-signed.pkg`.
3. This creates a unique CDN reference, e.g.: `%MosyleCDNFile:d4d8f767-3f99-4747-8041-253ea90c462d%`

## How to Perform an Upgrade

* The Nightfall Agent updates automatically.
* The Nightfall Profile will need updated from Mosyle if a new one is released.
* The Nightfall Extension updates automatically.

## How to Uninstall the Agent

{% hint style="info" %}
**NOTE**: The agent requires an uninstall command, but the profile is maintained through the MDM.  To remove the profile simply change the scope of devices the profile is deployed to or remove the profile to completely remove it from all of the targeted devices.  The extension will remove after closing the browser.
{% endhint %}

1. Unpack the zip file provided and locate the `mdm_nightfall_ai_agent_uninstall.sh` file in the `mdm_scripts` folder.
2. On Mosyle, navigate to **Management → Custom Commands**.
3. Paste the content of `mdm_nightfall_ai_agent_uninstall.sh` into the script editor.
4. Choose the device scope to deploy the command to.
5. Click **Save**.
6. Run immediately.
