Forum Discussion
JasonG91
Apr 25, 2024Copper Contributor
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 $CSVre...
JasonG91
Apr 26, 2024Copper Contributor
I would love to know the error but it just isnt giving one.
ill look into Microsoft Graph, Thanks
LainRobertson
Apr 26, 2024Silver Contributor
Here's your script with the try...catch block removed - perhaps save it as a different name while you diagnose the root issue.
If you run this version, you should see the real error(s) being listed.
If your CSV is large, consider reducing it in size for this diagnostic-only version of the script, as there's no value in having a thousand of the same error popping up.
$CSVrecords = Import-Csv C:\Temp\Test.csv -Delimiter ","
$SkippedUsers = @()
$FailedUsers = @()
foreach ($CSVrecord in $CSVrecords) {
$upn = $CSVrecord.UserPrincipalName
$user = Get-AzureADUser -Filter "userPrincipalName eq '$upn'"
if ($user) {
$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
}
else {
Write-Warning "$upn not found, skipped"
$SkippedUsers += $upn
}
}
Cheers,
Lain