Windows Autopilot deployment for existing devices: Create JSON file for Autopilot profiles

Autopilot user-driven Microsoft Entra join steps:

  • Step 3: Create JSON file for Autopilot profiles

For an overview of the Windows Autopilot deployment for existing devices workflow, see Windows Autopilot deployment for existing devices in Intune and Configuration Manager.

Create JSON file for Autopilot profiles

Note

The PowerShell code snippets in this section were updated in July of 2023 to use the Microsoft Graph PowerShell modules instead of the deprecated AzureAD Graph PowerShell modules. The Microsoft Graph PowerShell modules might require approval of additional permissions in Microsoft Entra ID when they're first used. For more information, see AzureAD and Important: Azure AD Graph Retirement and PowerShell Module Deprecation.

Once the proper modules are installed to allow exporting of Autopilot profiles from Intune, the next step is to export the Autopilot profiles as JSON files. The JSON files are used to create a package in Configuration Manager.

To export the Autopilot profiles as JSON files, follow these steps:

  1. Sign into the Configuration Manager site server or other device where the required modules were installed in the Install required modules to obtain Autopilot profiles from Intune step.

  2. On the device, open a PowerShell window as an administrator by right-clicking on the Start menu and selecting Windows PowerShell (Admin)/Windows Terminal (Admin) and then selecting Yes at the User Account Control (UAC) prompt.

  3. Copy the following commands by selecting Copy at the top right corner of the below PowerShell code block:

    Connect-MgGraph -Scopes "Device.ReadWrite.All", "DeviceManagementManagedDevices.ReadWrite.All", "DeviceManagementServiceConfig.ReadWrite.All", "Domain.ReadWrite.All", "Group.ReadWrite.All", "GroupMember.ReadWrite.All", "User.Read"
    $AutopilotProfile = Get-AutopilotProfile
    $targetDirectory = "C:\Autopilot"
    $AutopilotProfile | ForEach-Object {
        New-Item -ItemType Directory -Path "$targetDirectory\$($_.displayName)"
        $_ | ConvertTo-AutopilotConfigurationJSON | Set-Content -Encoding Ascii "$targetDirectory\$($_.displayName)\AutopilotConfigurationFile.json"
    }
    
  4. Paste the commands into the elevated PowerShell window and then select Enter on the keyboard to run the commands. If the elevated PowerShell command window isn't already signed into Intune, a Sign in to your account window appears. Sign in with a Microsoft Entra account that has access to Intune and the Autopilot profiles.

  5. Once signed into Intune, Enter might need to be selected a second time to run the last command in the code block.

  6. Once all the commands run successfully, the Autopilot profiles appears in a subfolder under the folder specified by the $targetDirectory variable. By default, the $targetDirectory variable is C:\AutoPilot, but it can be changed to another location if desired. The subfolder has the name of the Autopilot profile from Intune. If there are multiple Autopilot profiles, each profile has its own subfolder. In each folder, there's a JSON file named AutopilotConfigurationFile.json.

Note

The above script exports all Autopilot profiles from Intune. In addition to supported user-driven Autopilot profiles, it also downloads unsupported pre-provisioning Autopilot profiles and self-deploying Autopilot profiles if they exist in the environment.

Next step: Create and distribute package for JSON file in Configuration Manager

For more information on creating the JSON file, see the following articles: