power shell script - convert csv file into html format

I have power shell script below where I am trying to convert the csv file into an html file but it does not work. i would like it to send me an email daiyl using scheduled task but it does not work as it does not convert the csv file into an html file so what am I doing wrong.

Get-Eventlog -log system -after ((get-date).addDays(-1)) -EntryType Error, Warning | export-csv | convertto-Html | set-content C:\temp\sysevents.html

July 7th, 2013 9:40pm

Are you trying to save this as both CSV and HTML files, or only HTML?  If HTML is all you need, then removing the "export-csv" command from your pipeline should fix the problem.  Export-CSV is only for saving objects to a file in CSV format (and requires a -Path or -LiteralPath argument;  it won't work the way you were using it).  Export-Csv doesn't return any objects, and so can't be used in the middle of a pipeline like that.

Get-Eventlog -log system -after ((get-date).addDays(-1)) -EntryType Error, Warning | convertto-Html | set-content C:\temp\sysevents.html

Free Windows Admin Tool Kit Click here and download it now
July 7th, 2013 9:55pm

Is their a way that it can add the items into a table or something like that so everything is sorted evenly.
July 8th, 2013 6:06am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics