Creating an HTML report
In this recipe, we will create an HTML report based on the system's services.
How to do it...
This is a sample of how we can create an HTML report using PowerShell.
Open PowerShell ISE. Go to Start | Accessories | Windows PowerShell | Windows PowerShell ISE.
Add the following script and run it:
#simple CSS Style $style = @" <style type='text/css'> td {border:1px solid gray;} .stopped{background-color: #E01B1B;} </style> "@ #let's get content from Get-Service #and output this to styled HTML Get-Service | ConvertTo-Html -Property Name, Status -Head $style | Foreach { #if service is running, use green background if ($_ -like "*<td>Stopped</td>*") { $_ -replace "<tr>", "<tr class='stopped'>" } else { #display normally $_ } } | Out-File "C:\Temp\sample.html" -force Set-Alias ie "$env:programfiles\Internet Explorer\iexplore.exe" ie "C:\Temp\sample.html"
The following screenshot...