Tag Archives: Microsoft Lync

Update Microsoft Lync LineUri

Hey, today started with a meeting to discuss workflow for new user account creation.  It was quite interesting to properly think out the complete process with all the potential workflow snags, however in saying that our process is quite simply compared to some other organisations.

Following this meeting, i moved onto some work to update the “LineUri” property for our Lync enabled users.  When Lync was first deployed some of the lines were set incorrectly, and it was now time to update them as we begin to implement and deploy Lync to our users.  I achieved this with the following script.  This script is very specific to my organisation, but if you would like help adapting this script to your requirements let me know.

pseudo code: Get all Lync enabled users with phone numbers starting with “+61”.  For each user in the result, create some variables, and extract out the phone number and extension. Depending on the first number of the extension, build the $LineUri property, and then update the user.

$enabledUsers = Get-CsAdUser -Filter {Enabled -eq $true -and Phone -like '+612*'} foreach ($user in $enabledUsers) { $LineUri = $null

$phoneNumber = $user.Phone $phoneNumber = $phoneNumber -replace "[^0-9]" $tel = "TEL:+612" $ext = ";EXT=" $extension = $user.phone.substring($user.phone.length - 4,4) $extensiongroup = $user.phone.substring($user.phone.length - 4,1) Switch ($extensiongroup){ 5{$LineUri = $tel + "8853" + $extension + $ext + $extension} 4{$LineUri = $tel + "8846" + $extension + $ext + $extension} 3{$LineUri = $tel + "9775" + $extension + $ext + $extension} } try {

$user.DisplayName,$LineUri Set-CsUser -Identity $user.Identity -LineURI $LineUri } catch { Write-Warning $_.Exception.Message } }

Advertisements