none
Variable within a variable help RRS feed

  • Question

  • okay I have a script that imports a csv file and reads a file that has user data that include a the users name and phone number. My csv file has a column (depending on country) that has variables that put the phone number in the correct E164 format.

    If the user is Dan Smith and phone number 1234567890 then I import a $e164 string that is:

    $tel+$lineUri

    My existing variables are:

    $tel = "Tel:+1"

    $lineUri = "1234567890"

    I expect when I import the CSV file that my column for E164 will be:

    Tel:+11234567890

    not

    $tel+$lineUri

    How can I import the this CSV value and have it translate the values for the variables its importing???

    Wednesday, August 7, 2019 9:18 PM

All replies

  • You can't. You cannot store variables in a CSV.

    Please take the time to learn basic PowerShell and scripting.


    \_(ツ)_/

    Wednesday, August 7, 2019 9:52 PM
  • thanks. I am learning that's why I asked.
    Thursday, August 8, 2019 1:41 PM
  • $E164 = '$tel+$lineUri'      # Note single quote to not expand variables
    $tel = "Tel:+1"
    $lineUri = "1234567890"
    "The contents of my variables are {0} - {1} - {2}" -f $E164, $tel, $lineuri
    $expand164 = invoke-expression ("$E164")
    "Expanded E164 is {0}" -f $expand164  

    You will have to use invoke-expression to expand the data. 
    • Edited by MotoX80 Thursday, August 8, 2019 10:46 PM
    Thursday, August 8, 2019 10:42 PM
  • Yes - you can do that but you cannot do it on the import  without processing each line individually.


    \_(ツ)_/

    Thursday, August 8, 2019 11:02 PM