Create file from CSV

Welcome Forums General PowerShell Q&A Create file from CSV

Viewing 1 reply thread
  • Author
    • #212238
      Topics: 2
      Replies: 5
      Points: 33
      Rank: Member

      hi Guys.

      so I have a .csv file with a column called name. This column has different names and some with spaces in them.

      what I am looking to do is create a blank .cfg file based on the value of each row within column.

      any help on reading and creating the .cfg. I have thousands so don’t want to do this manually. Been ages since I played with PowerShell and need to find my head again with it.

      thanks in advance.

    • #212259
      Topics: 4
      Replies: 82
      Points: 251
      Helping Hand
      Rank: Contributor

      Well without seeing an example of the csv or an example of the output, I couldn’t be very specific.  Recommend looking at Import-Csv. This will import your file as an array of custom objects each with a “name” property.  From there depending on what you need to transform you could use a foreach loop or many other methods to transform each object. With an example, I might be able to recommend some other methods.  After any necessary transformation you could simply write the cfg with New-Item

Viewing 1 reply thread
  • You must be logged in to reply to this topic.