csv Output as html

Welcome Forums General PowerShell Q&A csv Output as html

This topic contains 1 reply, has 2 voices, and was last updated by

1 month, 3 weeks ago.

  • Author
  • #112141

    Points: 0
    Rank: Member


    I have this code, but i can't figure out how to print each line. Right now it only print the last line in the csv file

    $users = import-csv “C:\fso\names.csv”



    ForEach ($item in $users)





    $firstName = $item.(“fornavn”)

    $lastName = $item.(“efternavn”)


    Write-Output $firstname,$lastName




    ConvertTo-Html -Head $css -Body "Adresseliste`nGenerated on $(Get-Date)$firstname$lastname" | Out-File "C:\fso\test2.html"










  • #112145

    Points: 536
    Helping Hand
    Rank: Major Contributor

    \Not sure what you are trying to achieve. Are you trying to convert the CSV to html ? if so below is how to do that,

    Import-Csv -Path c:\yourcsv.csv | ConvertTo-Html -Property Porperty1,Propery2 | Out-File -FilePath c:\Report.html 

    You can add more beauty to the html using CSS. For that first you need to invest some time in learning and understanding how and where the cmdlets has to be used. Return of that investment will be huge.

    A great module for creating html reports,

    btwn, I would request you to use code posting tags while posting code in this forum. This will help in easily understanding your code.

You must be logged in to reply to this topic.