none
Convert Phone number to e.164 in powershell RRS feed

  • Question

  • Hey there, how can I convert users telephone numbers to e.164 format for Lync Line URI. for example.

    (A) In ad, phone numbers are entered in format +1 (403) 555-1234 X1234

    (B) For Lync, Line URI, we need them in format +14035551234;ext=1234

    I need a script line that will convert (A) to (B) format.

    Monday, July 18, 2011 6:16 PM

Answers

  • This wil pull out all of the chaff ->

    '+1 (403) 555-1234 X1234'-replace '\s|\(|\)|-','
    +14035551234X1234

    Try it until you see how it works then add this:

    ('+1 (403) 555-1234 X1234'-replace '\s|\(|\)|-','').Replace('X',';ext=')
    +14035551234;ext=1234

    This way is actually easier than trying to mix such a complex replacement code although some may be able to do it off the top of their head.

     Unfortunately the bad news is that will only work for US numbers as European and other numbers may be given in dotted format or with slashes. The is a Refex for that too.

     

     


    jv
    Monday, July 18, 2011 7:00 PM

All replies

  • This wil pull out all of the chaff ->

    '+1 (403) 555-1234 X1234'-replace '\s|\(|\)|-','
    +14035551234X1234

    Try it until you see how it works then add this:

    ('+1 (403) 555-1234 X1234'-replace '\s|\(|\)|-','').Replace('X',';ext=')
    +14035551234;ext=1234

    This way is actually easier than trying to mix such a complex replacement code although some may be able to do it off the top of their head.

     Unfortunately the bad news is that will only work for US numbers as European and other numbers may be given in dotted format or with slashes. The is a Refex for that too.

     

     


    jv
    Monday, July 18, 2011 7:00 PM
  • This wil pull out all of the chaff ->

    '+1 (403) 555-1234 X1234'-replace '\s|\(|\)|-','
    +14035551234X1234

    Try it until you see how it works then add this:

    ('+1 (403) 555-1234 X1234'-replace '\s|\(|\)|-','').Replace('X',';ext=')
    +14035551234;ext=1234

    This way is actually easier than trying to mix such a complex replacement code although some may be able to do it off the top of their head.

     Unfortunately the bad news is that will only work for US numbers as European and other numbers may be given in dotted format or with slashes. The is a Refex for that too.

     

     


    jv

    where can I find info on this part "'\s|\(|\)|-',"?  you can use multiple -replace and I started doing it that way and saw you replied first.
    Dan
    Monday, July 18, 2011 11:54 PM
  • where can I find info on this part "'\s|\(|\)|-',"?  you can use multiple -replace and I started doing it that way and saw you replied first.
    Dan


    Regular Expressions.

    They have been around for as long as I can remember.  ALmost all Unix people are very familiar with RegEx.

    http://en.wikipedia.org/wiki/Regular_expression

    http://www.regular-expressions.info/


    jv
    Monday, July 18, 2011 11:58 PM
  • where can I find info on this part "'\s|\(|\)|-',"?  you can use multiple -replace and I started doing it that way and saw you replied first.
    Dan


    Regular Expressions.

    They have been around for as long as I can remember.  ALmost all Unix people are very familiar with RegEx.

    http://en.wikipedia.org/wiki/Regular_expression

    http://www.regular-expressions.info/


    jv

    cool, I read the second link earlier and did not see a reference to /s
    Dan
    Tuesday, July 19, 2011 12:19 AM