Tuesday, February 25, 2014

How to locate users without the EXT in line uri and add it to them

Sometimes added users do not get their EXT set in their LineURI as they should, and it can be a frustrating to locate these users and to edit the lineURI to the proper format.

Fortunately, we have powershell for those kind of jobs. The following example will locate any csuser with a lineURI but without the extension set. Then add the extension to the lineURI and save the configuration.
$extSet = Get-CsUser -filter {lineuri -notlike "*ext*" -and lineuri -ne $null}
foreach ($user in $extSet){
$myURI = $user.lineuri
$myURI = $myURI + ";ext=" + $myURI.substring($myURI.length - "4") 
set-csUser -Identity $user.displayname -LineUri $myURI -verbose}

The example above will add the extension of 4. Edit this as fit for your environment.
I will add this example to the PsCommands sections as well