Bulk update Azure AD from Powershell – FAILED to update
Trying to run script to bulk update users attributes in AAD.
getting error (tried with multiple users)
what am I doing wrong here?
see below the script, the csv and the error
$CSVrecords = Import-Csv C:TempTest.csv -Delimiter “,”
$SkippedUsers = @()
$FailedUsers = @()
foreach ($CSVrecord in $CSVrecords) {
$upn = $CSVrecord.UserPrincipalName
$user = Get-AzureADUser -Filter “userPrincipalName eq ‘$upn'”
if ($user) {
try{
$user | Set-AzureADUser -jobTitle $CSVrecord.jobTitle -department $CSVrecord.department -officeLocation $CSVrecord.officeLocation -streetAddress $CSVrecord.streetAddress -city $CSVrecord.city -state $CSVrecord.state -postalCode $CSVrecord.postalCode -telephoneNumber $CSVrecord.telephoneNumber -mobile $CSVrecord.mobile
} catch {
$FailedUsers += $upn
Write-Warning “$upn user found, but FAILED to update.”
}
}
else {
Write-Warning “$upn not found, skipped”
$SkippedUsers += $upn
}
}userPrincipalName,jobTitle,department,officeLocation,streetAddress,city,state,postalCode,telephoneNumber,mobile
email address removed for privacy reasons,Title Test,Dept Test,Office Test,Street Test,City Test,State Test,Postcode Test,0111 1111111,07111 111111WARNING: email address removed for privacy reasons user found, but FAILED to update.
Trying to run script to bulk update users attributes in AAD. getting error (tried with multiple users)what am I doing wrong here? see below the script, the csv and the error $CSVrecords = Import-Csv C:TempTest.csv -Delimiter “,”
$SkippedUsers = @()
$FailedUsers = @()
foreach ($CSVrecord in $CSVrecords) {
$upn = $CSVrecord.UserPrincipalName
$user = Get-AzureADUser -Filter “userPrincipalName eq ‘$upn'”
if ($user) {
try{
$user | Set-AzureADUser -jobTitle $CSVrecord.jobTitle -department $CSVrecord.department -officeLocation $CSVrecord.officeLocation -streetAddress $CSVrecord.streetAddress -city $CSVrecord.city -state $CSVrecord.state -postalCode $CSVrecord.postalCode -telephoneNumber $CSVrecord.telephoneNumber -mobile $CSVrecord.mobile
} catch {
$FailedUsers += $upn
Write-Warning “$upn user found, but FAILED to update.”
}
}
else {
Write-Warning “$upn not found, skipped”
$SkippedUsers += $upn
}
}userPrincipalName,jobTitle,department,officeLocation,streetAddress,city,state,postalCode,telephoneNumber,mobile
email address removed for privacy reasons,Title Test,Dept Test,Office Test,Street Test,City Test,State Test,Postcode Test,0111 1111111,07111 111111WARNING: email address removed for privacy reasons user found, but FAILED to update. Read More