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
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:
#
#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
[COLOR=#CC0000]Below is where I am running into problems.
The .csv file is converted to html but I cannot get it to formatt.[/color]
#$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