Migrate Lync Users from One Pool to Multiple Pools Evenly With PowerShell

by Michael Epping

*UPDATE* Bill Hughes has posted his 1.1 version of the script, which is much better. Please go here to find it: http://www.concurrency.com/blog/migrate-lync-users-multiple-pools-powershell-episode-2/
Lync Server 2013 supports the fantastic new Pool Pairing feature for Standard Edition Pools, which seems to be a popular choice for many businesses. Recently I was in a situation where a customer had a few hundred users on their single Lync Server 2010 Pool. I wanted to quickly split their users into two groups of equal size and then move each group to one of the new Lync Server 2013 Standard Edition servers we had built. I wrote a very simple script that accomplishes this:
#####################################################
## CNCY-SplitCSPool_1_0.ps1 ##
## ##
## Version 1.0 ##
## Created 8/22/2013 ##
## ##
## Developed By: Michael Epping Concurrency ##
## Modified By: Bill Hughes Concurrency ##
## ##
## ##
## This script is provided as-is, no warrenty is provided or implied. ##
## The author is NOT responsible for any damages or data loss that may occur ##
## through the use of this script. Always test, before using any script ##
## in a production environment. ##
## ##
######################################################
#Create Functions
Function Check-Even ($num) {[bool]!($num%2)}
#Request Parameter Input
Param(
[Parameter(Mandatory=$True,Position=1)]
[string]$Lync2013Pool1,
[Parameter(Mandatory=$True,Position=2)]
[string]$Lync2013Pool2,
[Parameter(Mandatory=$True)]
[string]$Lync2010Pool
)
#Script Block
$csusers = Get-CsUser -Filter { RegistrarPool -eq "$Lync2010Pool" }
$csusercount = $csusers.count
$csuserhalfcount = $csusercount/2
$EvenOrOddNumberofUsers = (Check-Even $csuserhalfcount)
if ($EvenOrOddNumberofUsers -eq True) {
$pool1usercount = $csusercount/2
Get-CsUser -Filter { RegistrarPool -eq "$Lync2010Pool" } | Select-Object -First $pool1usercount | Move-CsUser -Target $Lync2013Pool1
Get-CsUser -Filter { RegistrarPool -eq "$Lync2010Pool" } | Move-CsUser -Target $Lync2013Pool2
}
else ($EvenOrOddNumberofUsers -eq False) {
$pool1usercount = ($csusercount/2) + .5
Get-CsUser -Filter { RegistrarPool -eq "$Lync2010Pool" } | Select-Object -First $pool1usercount | Move-CsUser -Target $Lync2013Pool1
Get-CsUser -Filter { RegistrarPool -eq "$Lync2010Pool" } | Move-CsUser -Target $Lync2013Pool2
}
Here it is in slightly more readable form:
Basically, the script asks the user for the name of the 2010 pool and the name of each of the 2013 pools. It then finds each user on the 2010 pool, divides that group in half, and distributes the two groups to each of the 2013 pools. Its pretty simple and is relatively effective.
Feel free to download it here: CNCY-SplitCSPool_1_0*UPDATE* Bill Hughes has posted his 1.1 version of the script, which is much better. Please go here to find it: http://www.concurrency.com/blog/migrate-lync-users-multiple-pools-powershell-episode-2/