Issues with escaping a semicolon ; in a LineURI string for Lync2013 Scripting

Welcome Forums General PowerShell Q&A Issues with escaping a semicolon ; in a LineURI string for Lync2013 Scripting

This topic contains 1 reply, has 2 voices, and was last updated by

3 years, 11 months ago.

  • Author
  • #23078

    Points: 0
    Rank: Member

    Hello All!

    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!

  • #23103

    Points: 0
    Rank: Member

    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"

    Gives me:


    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.

The topic ‘Issues with escaping a semicolon ; in a LineURI string for Lync2013 Scripting’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort