Edit

Share via


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

Windows Autopilot user-driven Microsoft Entra join steps:

  • Step 3: Create JSON file for Windows 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 Windows 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 Windows Autopilot profiles from Intune, the next step is to export the Windows Autopilot profiles as JSON files. The JSON files are used to create a package in Configuration Manager.

To export the Windows 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 Windows 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 Windows 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 Windows 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 Windows Autopilot profile from Intune. If there are multiple Windows 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 Windows Autopilot profiles from Intune. In addition to supported user-driven Windows Autopilot profiles, it also downloads unsupported pre-provisioning Windows Autopilot profiles and self-deploying Windows 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: