Recently, a customer asked me if it was possible to modify just the Domain in the SIP Address for multiple users in Lync. The answer is, of course, yes.
One User
It is possible to modify just the SIP address for a single user called Elvis Presley.
Assign a few variables
$user = Get-CSUser -id "Elvis Presley"
$sipAddress = $user.SipAddress
$newDomain = $sipAddress -replace "@OldDomain.com","@NewDomain.com"
Then run a single line to make the change.
Set-CsUser -Identity $user.Identity -SipAddress $newDomainSimple right?
All Users
What if you want to do it for all users? That's also possible.
Start by "getting" all users and assigning them to a variable
$users = Get-CSUserThen execute the following to make the change.
foreach ($user in $users)Specific Users
{
$sipAddress = $user.SipAddress
$newDomain = $sipAddress -replace "@OldDomain.com","@NewDomain.com"
Set-CsUser -Identity $user.Identity -SipAddress $newDomain
}
What if you only want to change the domain for a few users at a time? For instance, only for users assigned to a specific Security Group. That is also possible.
Start by "getting" a list of users that are a member of that security group.
$users = Get-ADGroupMember -Identity "Security Group" -Recursive | Select SamAccountNameThen execute the following to make the change.
foreach ($user in $users)Additional Filtering Options
{
$sipAddress = $user.SipAddress
$newDomain = $sipAddress -replace "@OldDomain.com","@NewDomain.com"
Set-CsUser -Identity $user.Identity -SipAddress $newDomain
}
There are many options for filtering users and returning a list.
By Email Domain
$users = Get-ADuser -Filter {(mail -like "*NewDomain.com")} | select name
By Organizational Unit
$ou = Get-ADOrganizationalUnit -Filter {name -like "OU Name"} | select -ExpandProperty distinguishedname
$users = Get-ADUser -Filter * -SearchBase $ou | select -ExpandProperty name
Getting Clever
I couldn't just leave it there, so I wrote an interactive script that asks for the Security Group, old and new domains, makes the changes and produces logs and a list of next actions.
The Script is available on the TechNet Gallery.
If you find this post useful please take a moment to share. Comments are welcome.
Thanks for reading.