March 6, 2015 at 8:15 am #23078
Hoping you can help me out, I am trying to pull the Telephone Number and IPPhone properties from AD objects and update the LineURI string on there Lync user. For some reason I can not get the stupid semicolon ; to properly display like below. I am a novice to scripting i haven't done it probably in about 5 years and i'm rusty on certain syntax, I did research and found some escaping characters for Powershell \ and ' but I can't seem to get it to work.
This is what i'm trying to accomplish:
By using this script:
$enabledUsers = Get-CsAdUser testuser
foreach ($user in $enabledUsers)
$phoneNumber = $user.Phone
$phoneNumber = $phoneNumber -replace "[^0-9]"
$extNumber = $user.IPPhone
$phonenumber = "TEL:+" + $phoneNumber + ";ext:" + $extNumber
Set-CsUser -Identity $user.Identity -LineUri $phoneNumber
This is the typical error I receive from Powershell:
PS C:\temp\junk> .\test_LINEURI.ps1
Set-CsUser : Extension token missing after telephone number. Specify the missing extension token and then try again.
At C:\temp\junk\test_LINEURI.ps1:10 char:9
+ Set-CsUser -Identity $user.Identity -LineUri $phoneNumber
+ CategoryInfo : NotSpecified: (:) [Set-CsUser], FormatException
+ FullyQualifiedErrorId : System.FormatException,Microsoft.Rtc.Management.AD.Cmdlets.SetOcsUserCmdlet
Any help would be appreciated, as i'm beating my head and can't find a way to get around this. THanks!
March 6, 2015 at 1:42 pm #23103
Are you sure escaping the semi-colon is your issue? I don't seem to have a problem putting semi-colons in strings.
$string1 = "PoSH" + ";" + "scripting" + ";" + "is" + ";" + "aggrivating" + ";" + "sometimes" $string1
In your script I see an extra "+" after "TEL:" which would be included in the string passed to the -LineUri parameter?
Might also help to see what you're passing to Set-CSUser by writing your variables to the screen before you execute that cmdlet. It's possible $user.IPPhone could be returning an array or something that's throwing things off.
You must be logged in to reply to this topic.