> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getprimo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrate from Intune to Primo

> Move Windows devices that are already enrolled in Microsoft Intune to Primo: Entra settings, agent deployment, migration script, and checks.

Move Windows devices that are enrolled in Microsoft Intune to Primo. The Primo agent moves the devices. If a device stays on Intune, a script is the fallback: see [Troubleshoot a device that stays on in another MDM](#troubleshoot-a-device-that-stays-on-in-another-mdm).

This article covers devices that are already enrolled in Intune. For new devices, use [zero-touch for Windows](https://docs.getprimo.com/mdm/zero-touch/zero-touch-windows.md). For Macs, see [Migrate Macs using Apple Business](https://docs.getprimo.com/mdm/rollout/migrating-macs-using-abm.md).

## Platform compatibility

| macOS | Windows | Linux | iOS / iPadOS | Android |
| - | - | - | - | - |
| ❌ | ✅ | ❌ | ❌ | ❌ |

## Prerequisites

* An admin account in the cockpit
* If you use an EDR: an exclusion for the agent (see **EDR exclusions (Windows)** in [Read before you start](#read-before-you-start))
* To change the MDM scopes in Entra: a Microsoft account with the **Global Administrator** role on your Entra tenant, and a licence that includes **Microsoft Entra ID P1** or **P2**. Microsoft lists [automatic MDM enrollment](https://learn.microsoft.com/en-us/intune/device-enrollment/windows/enable-automatic-mdm) as a premium Entra feature
* The `{company}` subdomain of your MDM address (`{company}.mdm.getprimo.com`). [Contact support](mailto:support@getprimo.com) if you don't know it

## Read before you start

> [!WARNING]
>
> **Back up the BitLocker recovery keys before you touch the devices in Intune or Entra.** Microsoft documents two behaviors that can lock employees out:
>
> * **Retire** and **Delete** in Intune remove an Entra joined device from Entra ID, so employees can no longer sign in with their Entra account. Intune also removes the key protectors of the operating system volume, which suspends BitLocker ([Microsoft Learn: Retire](https://learn.microsoft.com/en-us/intune/device-management/actions/retire)).
> * Deleting a device object in Entra removes the BitLocker keys attached to it, and Microsoft describes this as nonrecoverable ([Microsoft Learn: Manage device identities](https://learn.microsoft.com/en-us/entra/identity/devices/manage-device-identities)).
>
> Microsoft's Retire page also lists the credentials of a local administrator account as something to back up first. The steps below don't use Retire or Delete.
>
> > [accordion] EDR exclusions (Windows)
> >
> > If you use an EDR, exclude the agent before you deploy it. Otherwise the EDR can quarantine it, and the device can't migrate.
> >
> > Exclude the folder `C:\Program Files\Orbit`. If your EDR needs exact paths, exclude these files:
> >
> > * `C:\Program Files\Orbit\bin\orbit\orbit.exe` (the Primo agent)
> > * `C:\Program Files\Orbit\bin\osqueryd\osqueryd.exe` (the osquery daemon)
> > * `C:\Program Files\Orbit\bin\desktop\fleet-desktop.exe` (Fleet Desktop)
> >
> > For SentinelOne, add them as **Path** exclusions with **Include subfolders** and the **Interoperability** mode. On a SentinelOne instance provided by Primo, the exclusions are already set. See [Exclude the Primo agent from SentinelOne](https://docs.getprimo.com/mdm/endpoint-protection/sentinelone.md#exclude-the-primo-agent-from-sentinelone).

> [!NOTE]
>
> A Windows device has one MDM ([Microsoft Learn: MDM overview](https://learn.microsoft.com/en-us/windows/client-management/mdm-overview)). Microsoft Learn documents no procedure to move an Entra joined device from Intune to another MDM, and no effect of an MDM scope change on devices already enrolled in Intune. Run the whole procedure on one device you own before you move the others.

## Migrate with the agent

With **Automatic MDM migration** on, the Primo agent unenrolls the device from Intune, then enrolls it in Primo with the Fleet discovery URL, without going through Entra. The Entra MDM scope isn't needed for this method.

**1. Turn on Automatic MDM migration**

In the cockpit, go to **MDM > Settings**. In the **Enrollment** section, turn on **Automatic MDM migration**. It's off by default.

![Screenshot: The Enrollment section of MDM > Settings in the cockpit, with the Automatic MDM migration toggle off, its default state](https://mintcdn.com/primo/8MxefVhh0LHwpOzt/images/migrate-from-intune/cockpit-automatic-mdm-migration.png?fit=max\&auto=format\&n=8MxefVhh0LHwpOzt\&q=85\&s=86285c1cad2262ac0aee62b662c9fa9f)

With it on, the Primo agent on a Windows device enrolled in another MDM unenrolls the device from that MDM, then enrolls it in Primo. This applies to every device that has the agent and is enrolled in another MDM. See [MDM settings](https://docs.getprimo.com/mdm/settings#automatic-mdm-migration).

To also set the Intune MDM scope to `None` as a precaution, see [Move the device with a script](#move-the-device-with-a-script). This is the guidance of the Primo cockpit: Microsoft doesn't document what a scope change does to devices already enrolled.

**2. Deploy the agent through Intune**

Deploy the Primo agent to the devices you want to move, as a silent install through Intune. See [Silent agent deployment](https://docs.getprimo.com/mdm/rollout/silent-agent-deployment.md) for where to download the package.

A device appears in the cockpit with the status **On in another MDM** once the agent is installed. Without the agent, the cockpit doesn't see that the device is managed elsewhere.

If you deploy a generic installer, the cockpit may not know whose device it is. See [Use assignment suggestion](https://docs.getprimo.com/mdm/rollout/device-assignment.md#use-assignment-suggestion).

**3. Check the status**

In the cockpit, the device status goes from **On in another MDM** to **On**. See [Check the migration](#check-the-migration).

## Check the migration

* In the cockpit, the device's MDM status changes from **On in another MDM** to **On**.

* On the device, the active enrollment's `DiscoveryServiceFullURL` is your Fleet discovery URL, `https://{company}.mdm.getprimo.com/api/mdm/microsoft/discovery`. To list the values, run:

  ```powershell theme={null}
  Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Enrollments\" |
    ForEach-Object { (Get-ItemProperty Registry::$_).DiscoveryServiceFullURL }
  ```

* If a device stays on **On in another MDM** or goes back to Intune, see [Troubleshoot a device that stays on in another MDM](#troubleshoot-a-device-that-stays-on-in-another-mdm).

## Move your Intune policies to Primo

The settings that Intune applies are defined in Intune. To keep them after the move, recreate them in Primo before you move the devices. Microsoft documents that when Intune retires a device, the settings set by Intune policy are no longer enforced and users can change them ([Microsoft Learn: Retire](https://learn.microsoft.com/en-us/intune/device-management/actions/retire)). Learn doesn't document this for a device that leaves Intune through the agent, so check it on a pilot device.

1. List what to recreate. In the Intune admin center, go to **Devices > Manage devices > Configuration**. You can export a Settings catalog policy as JSON to read its settings ([Microsoft Learn: Settings catalog](https://learn.microsoft.com/en-us/intune/device-configuration/settings-catalog/)).
2. Look for a Primo control first. See the [available controls](https://docs.getprimo.com/mdm/policies/overview.md#available-controls).
3. For a Windows setting that no control covers, use [CSP Builder](https://csp-builder.getprimo.com) and the **Custom file** control. The Windows settings of the Settings catalog are generated from the Windows CSPs, and the **Learn more** link in a setting's tooltip opens its CSP (Microsoft Learn: Settings catalog). Find the same setting in the Policy CSP catalog of CSP Builder, set its value, and load the file on the Custom file control. See [Custom file](https://docs.getprimo.com/mdm/policies/custom-file.md#how-it-works).

CSP Builder doesn't import Intune profiles: it generates the file from the Policy CSP catalog. Primo doesn't check the settings inside a custom file, so test each one on a pilot device.

## Troubleshoot a device that stays on in another MDM

If a device keeps the status **On in another MDM** after the migration, check these points:

* **Automatic MDM migration** is on in **MDM > Settings**.
* The agent is installed and communicating. Without it, the cockpit can't migrate the device.
* The device isn't a Windows Server. The agent doesn't unenroll Windows Server devices.
* The agent spaces its attempts, so allow some time before you decide a device is stuck.
* The Intune scope is `None` (or a group that doesn't include the user), so the device doesn't go back to Intune.

For other statuses, see [Resolve enrollment issues](https://docs.getprimo.com/mdm/guides/resolve-enrollment-issues.md).

### Move the device with a script

If the checks above don't fix it, run the migration script on the device. The script goes through Entra automatic enrollment, so it needs what the agent method doesn't: the Fleet application and the MDM scopes in Entra. Microsoft doesn't document the `deviceenroller.exe` command the script uses, so test it on a pilot device.

**1. Open Mobility (MDM and WIP)**

In the Entra admin center, go to **Mobility (MDM and WIP)**. The list shows the applications that can enroll devices. You need **Fleet** and **Microsoft Intune** in it.

![Screenshot: The Mobility (MDM and WIP) page in the Microsoft Entra admin center, listing the Fleet and Microsoft Intune applications](https://mintcdn.com/primo/8MxefVhh0LHwpOzt/images/migrate-from-intune/entra-mobility-mdm-apps.png?fit=max\&auto=format\&n=8MxefVhh0LHwpOzt\&q=85\&s=b5423ebf60519dc196f73bb872970f1b)

**2. Create the Fleet application if it's missing**

The **Fleet** application is what tells Entra to send automatic enrollment to Primo. It holds the terms of use and discovery URLs of your MDM. Without it, the script can't enroll a device in Primo. If your devices come from Intune, you probably haven't created it yet:

* Click **+ Add application > + Create your own application**, enter `Fleet` as the name, and click **Create**.
* Set **MDM terms of use URL** to `https://{company}.mdm.getprimo.com/api/mdm/microsoft/tos` and **MDM discovery URL** to `https://{company}.mdm.getprimo.com/api/mdm/microsoft/discovery`, then save.
* Set the Application ID URI and the API permissions. The details are in **Create the Fleet application**, in step 3 (**Connect Azure and Fleet**) of [Set up zero-touch](https://docs.getprimo.com/mdm/zero-touch/zero-touch-windows.md#set-up-zero-touch).

Follow steps 1 to 3 of that article in order: connect Entra, declare the Fleet domain, and create the Fleet application. Each step unlocks the next. The domain step goes through Primo support and takes up to 2 business days, so start with it. Skip them if your Autopilot setup is already done.

**3. Set the Intune MDM scope to None**

Click **Microsoft Intune**, set **MDM user scope** and **WIP user scope** to `None`, and click **Save**. We recommend it, so that a device doesn't go back to Intune: this is the guidance of the Primo cockpit, and Microsoft doesn't document what a scope change does to devices already enrolled.

![Screenshot: The Microsoft Intune settings in Entra, with MDM user scope and WIP user scope set to None](https://mintcdn.com/primo/8MxefVhh0LHwpOzt/images/migrate-from-intune/entra-intune-mdm-user-scope-none.png?fit=max\&auto=format\&n=8MxefVhh0LHwpOzt\&q=85\&s=516707db315d04ae885f8f7cee53585c)

To move devices in batches, set the Intune **MDM user scope** to `Some` and select a group instead of `None`.

**4. Set the Fleet MDM scope**

Click **Fleet**, set **MDM user scope** to `All`, and click **Save**. To move devices in batches, set **Fleet** to `Some` with the group you move.

Only one MDM can have the `All` scope: Microsoft requires that no user belongs to more than one selected group and that no other application is set to `All` ([Microsoft Learn: Mobility scopes](https://learn.microsoft.com/en-us/windows-365/link/intune-automatic-enrollment)).

**5. Run the script**

The script removes the enrollment of your previous MDM from the Windows registry, then triggers a new enrollment. Replace `INPUT_URL_HERE` with the discovery URL of your previous MDM. To find it, read the `DiscoveryServiceFullURL` value under `HKLM:\SOFTWARE\Microsoft\Enrollments\` on a device enrolled in Intune.

> [accordion] Migration script (PowerShell)
>
> ```powershell theme={null}
> $EnrollmentsPath = "HKLM:\SOFTWARE\Microsoft\Enrollments\"
> $Enrollments = Get-ChildItem -Path $EnrollmentsPath
> $DiscoveryServerFullUrls = @("INPUT_URL_HERE")
>
> ForEach ($Enrollment in $Enrollments) {
>     $EnrollmentObject = Get-ItemProperty Registry::$Enrollment
>     if ($EnrollmentObject."DiscoveryServiceFullURL" -in $DiscoveryServerFullUrls ) {
>         $EnrollmentPath = $EnrollmentsPath + $EnrollmentObject."PSChildName"
>         Remove-Item -Path $EnrollmentPath -Recurse
>         & "C:\Windows\System32\deviceenroller.exe" /c /AutoEnrollMDM
>     }
> }
> ```

Run the script on one device first, your own. Then move the others one by one, or all at once with a policy.

**6. Run the script with a policy**

For many devices, use a policy in the [Fleet console](https://docs.getprimo.com/mdm/get-started/navigating-fleetdm.md). Upload the script to **Controls > Scripts**, create a policy with the query below, and link the script to it.

The policy passes when the device has no enrollment left with another discovery URL, and fails when it still has one. Fleet runs the linked script when the policy fails on a device: the first time it fails, and each time it goes from passing to failing.

> [accordion] Policy query for batch migration
>
> Replace `{company}` with your subdomain:
>
> ```sql theme={null}
> SELECT 1 WHERE NOT EXISTS (
>   SELECT 1 FROM registry
>   WHERE path LIKE 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Enrollments\%%'
>   AND name = 'DiscoveryServiceFullURL'
>   AND data NOT IN ('https://{company}.mdm.getprimo.com/api/mdm/microsoft/discovery')
> );
> ```

## If you also use Autopilot

Autopilot is a separate job from the migration. It applies to new or reset devices. Microsoft downloads the Autopilot profile when a device first starts and doesn't replay it on a device that is already provisioned ([Microsoft Learn: Autopilot FAQ](https://learn.microsoft.com/en-us/autopilot/troubleshooting-faq)).

* Zero-touch needs the Fleet scope set to `All`, as in [Move the device with a script](#move-the-device-with-a-script). The other steps (deployment profiles, device registration, testing) are in [Zero-touch for Windows](https://docs.getprimo.com/mdm/zero-touch/zero-touch-windows.md). That article has you create deployment profiles in Microsoft's Intune admin center. This is the Autopilot service, not the MDM enrollment of your devices.
* Don't delete Autopilot devices or their Entra objects as part of the migration. Microsoft warns that deleted system-managed devices can't be reprovisioned ([Microsoft Learn: Stale devices](https://learn.microsoft.com/en-us/entra/identity/devices/manage-stale-devices)).

## Related articles

* [Enrollment overview](https://docs.getprimo.com/mdm/rollout/enrollment-methods.md)
* [Silent agent deployment](https://docs.getprimo.com/mdm/rollout/silent-agent-deployment.md)
* [Set up zero-touch deployment for Windows](https://docs.getprimo.com/mdm/zero-touch/zero-touch-windows.md)
* [Device assignment](https://docs.getprimo.com/mdm/rollout/device-assignment.md)
* [Resolve enrollment issues](https://docs.getprimo.com/mdm/guides/resolve-enrollment-issues.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.