locked
How to build PATH with info issued from CSV file ? RRS feed

  • Question

  • Hello team !

    I'have a basic issue here, i'am wondering how i can build a path with information issued from simple CSV file which headers are : 

    hostname,domain

    Server1,DomainA

    I want to build this path : 

    $Path = D:\Test_folder
    
    Export-Csv $Path\Services\$server.hostname-Services.csv -notype
    

    Error : 

    At line:168 char:34
    +                             $Path\Services\$server.hostname+-Services.csv
    +                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Unexpected token '\Services\$server.hostname+-Services.csv' in expression or statement.

    Your help is really appreciated as i'am getting white hair since serveral hours on googling without any result.

    Tuesday, June 12, 2018 11:35 AM

Answers

  • Try this:

    Export-Csv "$Path\Services\$($server.hostname)-Services.csv"


    • Edited by TobyU Tuesday, June 12, 2018 11:42 AM
    • Marked as answer by Labark Tuesday, June 12, 2018 11:46 AM
    Tuesday, June 12, 2018 11:42 AM

All replies

  • Try this:

    Export-Csv "$Path\Services\$($server.hostname)-Services.csv"


    • Edited by TobyU Tuesday, June 12, 2018 11:42 AM
    • Marked as answer by Labark Tuesday, June 12, 2018 11:46 AM
    Tuesday, June 12, 2018 11:42 AM
  • Bingo that's do correctly the job ! 

    Many thanks and have a great day ! You've made mine happy for sure :)

    Tuesday, June 12, 2018 11:46 AM