How To Bulk add Computer Names to an Entra ID Group
So turns out its not an easy task to just add computer names to a CSV file and upload it to your Entra ID Group as the bulk upload template has a field where you need to add the object id only.
As per Picture above, when you hit "Bulk Operations" & select "import member", it then gives you an option to download the CSV file as template.
Now in the downloaded CSV, you need to add the ObjectID[s], in place of Example.
This leads to 2 steps Solution:
1 > Use PowerShell to extract object Ids into a CSV file, for this you need to add the computer names first in a text file, so our PowerShell goes through each computer and give us the ObjectIDs in another separate CSV file as output, lets call it CSV#2
You can modify as per your needs.
*********************************************************************
# Install the AzureAD module if not already installed
Install-Module -Name AzureAD
# Connect to Azure AD
Connect-AzureAD
# Path to your text file containing computer names
$ComputerListPath = "C:\Computernames.txt"
# Read the list of computer names from the text file
$ComputerNames = Get-Content -Path $ComputerListPath
# Initialize an array to hold device information
$DeviceInfo = @()
# Loop through each computer name
foreach ($ComputerName in $ComputerNames) {
# Retrieve device information from Azure AD
$Device = Get-AzureADDevice -Filter "DisplayName eq '$ComputerName'"
if ($Device) {
# Add the device info to the array
$DeviceInfo += $Device | Select-Object DisplayName, ObjectId
} else {
# Output a warning if the device is not found
Write-Host "Device '$ComputerName' not found in Azure AD." -ForegroundColor Yellow
}
}
# Export the device information to a CSV file
$ExportPath = "C:\Users\username\Documents\ObjectID_devices.csv"
$DeviceInfo | Export-Csv -Path $ExportPath -NoTypeInformation
# Confirm completion
Write-Host "Device information exported to $ExportPath" -ForegroundColor Green
*********************************************************************
2> Copy your object Ids you got from the CSV#2 and add it to the Template CSV you downloaded earlier from Azure earlier
Now it is just matter of uploading your Template CSV by going to your Group in Entra ID