Forum Discussion
Bulk update Azure AD with user attributes from CSV
- May 08, 2020
Hello Jacob,
Your CSV has to look something like this:
UserPrincipalName;Department;TelephoneNumber
manfreddelaat@domain.nl;IT;0135113333
manfred@domain.nl;IT;0622222222Your Powershell code:
# Connect to AzureAD Connect-AzureAD # Get CSV content $CSVrecords = Import-Csv C:\Temp\Test.csv -Delimiter ";" # Create arrays for skipped and failed users $SkippedUsers = @() $FailedUsers = @() # Loop trough CSV records foreach ($CSVrecord in $CSVrecords) { $upn = $CSVrecord.UserPrincipalName $user = Get-AzureADUser -Filter "userPrincipalName eq '$upn'" if ($user) { try{ $user | Set-AzureADUser -Department $CSVrecord.Department -TelephoneNumber $CSVrecord.TelephoneNumber } catch { $FailedUsers += $upn Write-Warning "$upn user found, but FAILED to update." } } else { Write-Warning "$upn not found, skipped" $SkippedUsers += $upn } } # Array skipped users # $SkippedUsers # Array failed users # $FailedUsers
Good luck!
Kind Regards, Manfred de Laat
- Kevin_MorganNov 15, 2023Iron Contributor
Hi, You have to use the ExtensionProperty to set the null value or clear the property with Set-AzureADUser cmdlet.
$properties = [Collections.Generic.Dictionary[[String],[String]]]::new() $properties.Add("Mobile", [NullString]::Value) Set-AzureADUser -ObjectId "email address removed for privacy reasons" -ExtensionProperty $properties # Refer to the below post for more details. # https://morgantechspace.com/2022/03/update-bulk-azure-ad-user-attributes-using-powershell.html
Check this post for more details: Remove or Clear Property or Set Null value using Set-AzureADUser cmdlet
Check out this link from specmasoft to update bulk user attributes, including setting a manager, updating licenses, and managing extension attributes (e.g., employeeId). You can also set null values or clear existing property values. Additionally, the tool allows you to update passwords for bulk users and add multiple users to any groups or teams.
Update Bulk User Information in Microsoft 365 using a CSV file
- rogerdodgerNov 21, 2023Copper Contributorso any other set attribute does not get touched at all, correct? I"m only looking to update Titles and plan on testing this but obv don't want anything else to change on the users. . .
# Connect to AzureAD
Connect-AzureAD
# Get CSV content
$CSVrecords = Import-Csv C:\Temp\Test.csv -Delimiter ";"
# Create arrays for skipped and failed users
$SkippedUsers = @()
$FailedUsers = @()
# Loop trough CSV records
foreach ($CSVrecord in $CSVrecords) {
$upn = $CSVrecord.UserPrincipalName
$user = Get-AzureADUser -Filter "userPrincipalName eq '$upn'"
if ($user) {
try{
$user | Set-AzureADUser -JobTitle $CSVrecord.JobTitle
} catch {
$FailedUsers += $upn
Write-Warning "$upn user found, but FAILED to update."
}
}
else {
Write-Warning "$upn not found, skipped"
$SkippedUsers += $upn
}
}
# Array skipped users
# $SkippedUsers
# Array failed users
# $FailedUsers