February 2019
Intermediate to advanced
626 pages
15h 51m
English
HTML content can be enhanced by adding a Cascading Style Sheet (CSS) fragment. When CSS is embedded in an HTML document, it is added between style tags in the head element.
The following style uses CSS to change the font, color the table headers, define the table borders, and justify the table content:
$css = @'
<style>
body { font-family: Arial; }
table {
width: 100%;
border-collapse: collapse;
}
table, th, td {
border: 1px solid Black;
padding: 5px;
}
th {
text-align: left;
background-color: LightBlue;
}
tr:nth-child(even) {
background-color: GainsBoro;
}
</style>
'@
The Head parameter of ConvertTo-Html is used to add the element to the document:
Get-Process | ConvertTo-Html -Property Name, Id, WorkingSet -Head $css | Set-Content ...
Read now
Unlock full access