Good day all -
Following this blog here (http://blogs.technet.com/b/nexthop/archive/2011/02/01/howtoadphonetolineuri.aspx) to manipulate phone number is our AD organization. Unfortunately when Lync populates the contact field from AD it looks at the Telephone Number and Office Number. In our organization these numbers are reversed. Meaning, the 10 digit number is xxx.xxx.xxxx is listed in the "Office" field of AD and the 4 Digit Extension is listed in the "Phone". With that said, we do have have different calling blocks. Meaning must of our numbers are:
555.555.9xxx
and 555.556.6xxx
All internal extensions (listed in the Telephone number field) begin with 5 and would be replaced with the last xxx in the above example.
So for the 555.250.9xxx block would be 200-499 .... for example extension 5394 would be Direct Dial Number 555.555.9394
And for the 555.556.6xxx block would be 600-799 ... for example extension 5657 would be Direct Dial Number 555-555.6657
So my question is this...with the above - how can I populate the below script correctly? Thanks for helping out.
$enabledUsers = Get-CsAdUser -Filter {Enabled -ne $Null}
foreach ($user in $enabledUsers)
{
$phoneNumber = $user.Phone
$phoneNumber = $phoneNumber -replace "[^0-9]"
$extension = $phoneNumber -match "^5"
if ($extension)
{
$phoneNumber = "TEL:+120655" + $phoneNumber
}
else
{
$phoneNumber = "TEL:+142556" + $phoneNumber
}
Set-CsUser -Identity $user.Identity -LineUri $phoneNumber
}