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 # $FailedUsersGood luck!
Kind Regards, Manfred de Laat
jebujohnYou're welcome! Take care! ![]()
- Jacob JohnMay 22, 2020Copper Contributor
Dear Manfred101,
In the same scenario if I wanted to add -EmployeeID from a csv, would it be possible to use a similar script. -EmployeeID seems to be an azureaduserextension.
Jacob
- Manfred101May 22, 2020Iron Contributor
Jacob John Just add this line below line 17:
$user | Set-AzureADUserExtension -ExtensionName "employeeId" -ExtensionValue $CSVrecord.employeeIdAnd make sure you add the "employeeId" records are present in your CSV file.
Good Luck!
Grtz, Manfred de Laat
- TamerhalawahNov 27, 2020Copper Contributor
can you please advice how i can change the manager in bulk for all employees?
there is just one manager account and 130 employees, all of them need to have this manager in Azure AD in order for a flow to work.
thanks