×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Need Help formatting html output

Need Help formatting html output

Need Help formatting html output

(OP)
I am very new to Powershell. I managaged to create a script and have it execute via a .bat file.

My problem is the output is not very user friendly so I wanted to add some HTML to make the output more easy to read.

The code below shows what I am trying to do but I only get the heading and background color as the output. There is no detail.

Can you please let me know what I am doing wrong. i am using V1.0

CODE --> V1.0

#
#Get System Event Errors except for those liste in $APPevents above
#
$SysEvent = get-EventLog -logname Application -newest 2000 -ComputerName $Servers | where-object {$APPevents -notcontains $_.eventid}
$SysError = $SysEvent |where {$_.entryType -match "Error"}
$APPCSVPath = "C:\z_Application_EventViewerErrors.csv" # The files where Application Events are written to
$SysError | sort TimeWritten  –Descending| `
select TimeWritten, eventid, machinename, entrytype, source, message `
| Export-Csv $APPCSVPath -NoTypeInformation 

Below is where I am running into problems.  
The .csv file is converted to html but I cannot get it to formatt.

#$html = Import-CSV C:\z_Application_EventViewerErrors.csv | ConvertTo-HTML `
$a = "<style>"
$a = $a + "BODY{background-color:peachpuff;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:PaleGoldenrod}"
$a = $a + "</style>"
$html = Import-CSV C:\z_Application_EventViewerErrors.csv
select TimeWritten, eventid, machinename, entrytype, source, message |
ConvertTo-HTML -head $a -body  "<H2>Application Errors</H2>" | 
Set-Content c:\z_Application_EventViewerErrors.html 

RE: Need Help formatting html output

(OP)
Never mind. I figured it out.

CODE --> V1.0

$a = "<style>"
$a = $a + "BODY{background-color:peachpuff;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:PaleGoldenrod}"
$a = $a + "</style>"
$html = Import-CSV C:\z_Application_EventViewerErrors.csv |
ConvertTo-HTML TimeWritten,EventID,MachineName,EntryType,Source,Message -body $a "<H2>Application Errors</H2>" | 
Set-Content c:\z_Application_EventViewerErrors.html 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close