I wrote this quick PowerShell script when I needed to import some phone number data from the Lync Line URI attributes within Lync 2010 and place it in Active Directory.
This script is provided as-is, and I hope it provides you a head start if your looking to complete a similar task. You will need to customise the script to your requirements, in my case I needed 4 digit extension numbers from the Lync Line URI to be held within the AD IPPhone attribute, a one off task to back-port some data into AD before I used set-lineuri-from-ad.ps1 for future Line URI updates.
To test this command, you could restrict its scope by matching a specific user, eg: Get-CsAdUser -LdapFilter “IPPhone=1234”, or by OU as shown in the script. You also need to set the if statement as required.
# set-adipphone-from-lineuri.ps1 # Back-port 1xxx number from users Lync lineuri into their AD IPPhone attribute. # 2013-07-25 - R. Jervis Import-Module ActiveDirectory #$RJUsers = Get-AdUser -Filter {msRTCSIP-Line -like "tel:+1*"} -Properties * $RJUsers = Get-AdUser -LDAPFilter "(msRTCSIP-Line=tel:+1*)" -SearchScope Subtree -SearchBase "OU=Test Users,DC=test,DC=local" -Properties * foreach ($user in $RJUsers) { Write-Host --------------------------------------------------------------------------------- Write-Host Back porting $user.SamAccountName with LineURI $user["msRTCSIP-Line"] -NoNewLine ; Write-Host $RJURI = $user."msRTCSIP-Line" $RJURI = $RJURI.Substring(5,4) Write-Host $RJURI Write-Host $user.ipphone if ($RJURI -like '1234') { echo "Lync Ext: $RJURI" $RJUserMod = Get-ADUser $user.SamAccountName -Properties ipPhone $RJUserMod.ipPhone = $RJURI Write-Host SETTING USER! Set-ADUser -instance $RJUserMod } }






