Author Posts

July 26, 2018 at 4:16 pm

I have a script to input the office phone numbers after I strip all off the items not needed like ( ), +, or -.
After that I'd like to simply add a +1 to the beginning of each phone number. Right now this is what I have to do the formatting and removal that spits out the phone number in a 9 digit format which is perfect. Just that last final leading +1 at the beginning i'm stuck on.

  #Formats Removes Symbols and spaces from the telephone number
                $teltemp = $employee.'Business_Phone'.Trim().Replace('/','').Replace('-','').Replace('   ','').Replace('  ','').Replace(' ','').Replace('+','')
                #Remove any leading 1 from the telephone (10 digit to 9 digit)
                $telephone =  $teltemp  #-Replace '^1',''          

Any suggestions? I'd like to keep this as straight forward and simple as possible.


July 26, 2018 at 4:37 pm

You can look at examples of string concantenation, but this is a string format:

$telTemp = "5551234567"

$telTemp = '+1{0}' -f $telTemp


July 26, 2018 at 4:40 pm

I think that did it! I was super close! 😀 LOL...part I missed was location of the brackets.

I was testing with {+10} -f $teltemp both with single and double quotes.

Thanks a lot!! Easy one huh? :))