Some simple Powershell commands to distribute users in a Skype/Lync Pool by A-K and L-Z

Hi All

I recently wanted to script up distributing users A-K and L-Z across two EE pools. I wanted to something quick and dirty, so this is by no means elegant (which I am hoping to work on :)). But in case you want to do something like this please feel free to use.

Happy Skype/Lync'ing

Steve

PS Make sure you test in a dev environment before you run this.

##-----------------------------------------------------------------------

## Function: Move-UserBySurname
##-----------------------------------------------------------------------

function Move-UserBySurname
{

 

param ([string]$strFilter,[string]$strPoolName,[bool]$UpdateUser=$False)

 

[string] $strResult = "";

$i=0
Get-CsADUser -Filter {enabled -eq $True -and lastname -like $strFilter} | %{

$strSIP=$_.SipAddress

## If UpdateUser flag not set, no update happens, good for testing

write-host "$i - Processing $strSIP"

If ($UpdateUser) {move-csuser -Identity $strSIP -Target $strPoolName -Confirm:$false}
$i++

 }

 

}

##-----------------------------------------------------------------------

## Alter the UpdateUser flag to $False if you want to just do a quick scan but not move

$UpdateUser=$True

$strPool1="Skypepool1.lab1.org"

$strPool2="Skypepool2.lab1.org"

 

## I am being lazy here and not including all the letters of the alphabet. was thinking of something more graceful, but got bored :)

$ary="a*","b*","c*","d*","e*","f*","g*","h*"

 

foreach ($strSurname in $ary) {

cls

write-host "Processing $strSurname"

Move-UserBySurname $strSurname $strPool1 $UpdateUser

}

 

## I am being lazy here and not including all the letters of the alphabet. was thinking of something more graceful, but got bored :)

$ary="l*","m*","n*","o*","p*","q*","r*","s*"

 

foreach ($strSurname in $ary) {

cls

write-host "Processing $strSurname"

Move-UserBySurname $strSurname $strPool2 $UpdateUser

}

 

Below is a sample of me running a cut down version of the script. I am also using a filtered OU to restrict even further, which might be something you want to play with. NOTE: $UpdateUser is set to $False as I am playing around.