Modify msExchHomeServerName AD attribute for all users in a specific Exchange Database

Is there a way of modifying 'msExchHomeServerName' Active Directory attribute for all users that are located in a specific Exchange 2010 Database?
 
Thanks for your help.
LVL 1
the_omnificAsked:
Who is Participating?
 
Justin YeungSenior Systems EngineerCommented:
import-module ActiveDirectory
$newhomevalue = "newservername"
$databasename = "your database"

#get users in database from $databasename
$Users = Get-Mailbox -database $databasename

#set every object with msExchHomeServerName to $newhomevalue
foreach ($User in $users)
{
set-aduser $user.SamAccountName -Replace @{msExchHomeServerName=$newhomevalue}
}
0
 
yo_beeDirector of Information TechnologyCommented:
What happened that you need to manually change this attribute?
0
 
the_omnificAuthor Commented:
It's pointing at the wrong Exchange server and CommVault is failing to see these mailboxes. When I manually change this attribute CommVault works successfully.
 
This is why I need this command.
 
Thanks.
0
How do you know if your security is working?

Protecting your business doesn’t have to mean sifting through endless alerts and notifications. With WatchGuard Total Security Suite, you can feel confident that your business is secure, meaning you can get back to the things that have been sitting on your to-do list.

 
yo_beeDirector of Information TechnologyCommented:
How many users are we talking about?
0
 
Justin YeungSenior Systems EngineerCommented:
$OU = "ou=1,dc=2,dc=3,dc=4"
$newhomevalue = "newservername"

$users = get-aduser -filter * -searchbase $OU

foreach ($User in $users)
{
set-aduser $user.samaccountname -Replace @{msExchHomeServerName=$newhomevalue}
}
0
 
the_omnificAuthor Commented:
Thanks but I need a command to run for all users that are located in a specific Exchange 2010 Database. Not Active Directory
0
 
the_omnificAuthor Commented:
PERFECT ANSWER!
 
Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.