With this procedure you are able to bulk add Device Names to Autopilot devices.
This is not possible via import.
First we need to Install Autopilot Powershell module
Start Administrative powershell
Install-Module -Name WindowsAutoPilotIntune
Now we need to Export autopilot devices with a certain group tag
Connect-MSGraph
Update-MSGraphEnvironment -SchemaVersion "Beta" -Quiet
Connect-MSGraph -Quiet
Get-AutopilotDevice | Where-Object {$_.GroupTag -eq 'EN - WML - 06-01-2023' -and (-Not $_.DisplayName)} | Export-Csv AutopilotDevices.csv -encoding UTF8 -NoTypeInformation -Force
At this point we gonna Prepare an Excel / .csv file which we use for the upload.
I had to combine data out of 2 excel workbooks and used a great function in Excel : XLOOKUP.
Short video which explains this function : Using XLOOKUP Across Multiple Workbooks – Bing video
AutopilotDevices.csv
In an Excel cell, type =xlookup and fill in the values.
Select lookup value, here you choose the a value in a cell which you want to lookup
then select where we want to lookup this value -> switch to other excel workbook and select the cells or the column what to lookup
Then you need to tell when it finds a match what to do, so select the cells or the column with the values what to return.
So the formula I used looked like this :
=XLOOKUP, (lookup value), (where to lookup),(what value)
=XLOOKUP([@serialNumber];'[Surface9-20230109.xlsx]Blad1′!$C$2:$C$126;'[Surface9-20230109.xlsx]Blad1′!$A$2:$A$126)
Now we gonna Format the excel workbook in the correct .csv format
Save the excel file as .csv
Import-Csv ".\AutopilotDevicesWithDisplayName-Excel.csv" -Delimiter ";" | Export-Csv ".\AutopilotDevicesWithDisplayName.csv" -NoTypeInformation
Another option is to use the formula = TEXTJOIN.
Add an extra column to your Excel, use this formula =TEXTJOIN(“,”,FALSE,A1,B1,C1,E1)
Copy the content of this column to Notepad ++ and save as a .csv.
Upload / Import the file into intune.
When we have the correct file we are going to use powershell again to import this file.
import-csv AutopilotDevicesWithDisplayName.csv | foreach {Set-AutopilotDevice -id $_.id -ComputerName $_.displayname -groupTag $_.grouptag}
Invoke-AutopilotSync