Bulk Add Windows Autopilot Devices to Entra ID Groups Using Only Serial Numbers

If you manage Windows Autopilot at scale, you will know how painful it is trying to add devices into Entra ID groups when all you have is a list of serial numbers.

Entra bulk upload does not accept serial numbers. It only accepts:

  • Device object IDs

  • Or user UPNs

This guide shows you how to turn a simple Notepad list of serial numbers into a ready-to-upload CSV file that Entra accepts.

No manual lookups. No clicking through portals.


Why this is useful

This method is perfect when:

  • You have received a bulk shipment of new laptops.

  • Devices are already imported into Windows Autopilot.

  • You need to quickly target them with:

    • Configuration profiles

    • ESP profiles

    • App deployments

    • Compliance policies

Instead of adding each device one-by-one, you can generate the CSV in seconds.


Step 1 – Create your serial number file

Create this file:

D:\serials.txt

Add one serial number per line:

PF3ABC123
5CD0123XYZ
DL09KLM456

Step 2 – Install Microsoft Graph PowerShell (one time only)

Open PowerShell as yourself and run:

Install-Module Microsoft.Graph -Scope CurrentUser -Force

Step 3 – Run the conversion script

This script:

  • Reads your serial list

  • Finds the matching Autopilot records

  • Maps them to Entra device object IDs

  • Creates the CSV file ready for bulk upload

$serialFile = "D:\serials.txt"
$outCsv = "D:\group-members.csv"

$serials = Get-Content $serialFile | ForEach-Object { $.Trim() } | Where-Object { $ }

Import-Module Microsoft.Graph.DeviceManagement.Enrollment
Import-Module Microsoft.Graph.Identity.DirectoryManagement

Connect-MgGraph -Scopes "DeviceManagementServiceConfig.Read.All","Device.Read.All"

$apDevices = Get-MgDeviceManagementWindowsAutopilotDeviceIdentity -All

$rows = foreach ($s in $serials) {
 
$ap = $apDevices | Where-Object { $_.SerialNumber -eq $s } | Select-Object -First 1 if (-not $ap) { continue } if (-not $ap.AzureActiveDirectoryDeviceId) { continue } $aad = Get-MgDevice -Filter "deviceId eq '$($ap.AzureActiveDirectoryDeviceId)'" -Property Id | Select-Object -First 1 if (-not $aad) { continue } [pscustomobject]@{ memberObjectIdOrUpn = $aad.Id }
} $rows | Export-Csv -Path $outCsv -NoTypeInformation -Encoding UTF8

Step 4 – Upload to your Entra group

Your CSV will now exist here:

D:\group-members.csv

Go to:

Entra admin centre → Groups → your device group → Members → Bulk add members

Upload the CSV file and your devices will be added instantly.


Common issues

Autopilot record exists but device is skipped
The device has never enrolled yet, so it does not have an Entra object ID.

403 Forbidden error
Your account does not have permission to read Autopilot devices. You will need:

  • Intune role that allows reading Autopilot devices

  • Or admin consent for DeviceManagementServiceConfig.Read.All


This process turns what used to be a 30-minute manual job into a 30-second task and works perfectly for laptop refresh projects, Intune migrations, and large Autopilot rollouts.

Total
0
Shares
Previous Post

Spreading Christmas Cheer with PowerShell

Next Post
Fix Windows Audio & Chrome Call Issues with One PowerShell Script

Fix Windows Audio & Chrome Call Issues with One PowerShell Script

Related Posts

Copy Files and Folders to User Computers via GPO

You can use Group Policies to copy specific files and folders to user computers in the Active Directory domain. You can place files on the Desktop, in a particular user profile directory, or in any other folder on a local drive. With GPO, you can automatically copy and update various configuration files, INI files, app
Read More