csv Output as html

Hi

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”

 

 

 

 

 

 

}

 

 

\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,
https://www.powershellgallery.com/packages/EnhancedHTML2/2.0

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