How can I bulk update custom attributes in Exchange for 1000 users?

0
0
Asked By CuriousCat123 On

I'm looking for advice on efficiently updating a custom attribute in Exchange for a large number of users. Specifically, we are replacing a custom link tied to 'Custom Attribute 4' from 'examplewebsite.c' to 'examplewebsite2.c' for around 1000 user accounts. I have a spreadsheet prepared, but I'm unsure if this process can be automated with PowerShell or if I'll need to do it manually. Any help with scripts or best practices would be greatly appreciated!

2 Answers

Answered By TechWiz99 On

Since you're dealing with a spreadsheet, here's a quick PowerShell script you could try. First, ensure your CSV is structured like this:

UserPrincipalName,NewWebsiteLink
[email protected],examplewebsite2.c/user1
[email protected],examplewebsite2.c/user2

Then, use this script:

Connect-ExchangeOnline
$users = Import-Csv -Path "C:PathToyourfile.csv"
foreach ($user in $users) {
try {
Set-Mailbox -Identity $user.UserPrincipalName -CustomAttribute4 $user.NewWebsiteLink
Write-Host "Updated $($user.UserPrincipalName) successfully." -ForegroundColor Green
} catch {
Write-Host "Failed to update $($user.UserPrincipalName): $_" -ForegroundColor Red
}
}
Disconnect-ExchangeOnline

Make sure to test it on a small group first to confirm it works correctly!

DataGuru88 -

That's a solid script! For those who prefer formulas, another approach is to set up a command in Excel that assembles the PowerShell command per row. Just copy it into PowerShell later. It makes it easier to manage multiple updates without the risk of a foreach loop mishap.

Answered By SysAdminPro On

Keep in mind that if you're in a hybrid setup, you'll need to perform these updates on-prem with Active Directory. Try using `set-aduser` instead, with a syntax like:

set-aduser -id $user -replace @{extensionattribute4=$newvariable}

Just remember to ensure your data is accurate, as that can make or break the bulk update.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.