Creating an HTML report
In this recipe, we will create an HTML report based on the system's services.
How to do it...
These are the steps required to create an HTML report using PowerShell:
- Open PowerShell ISE as an administrator.
- 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 a styled HTML Get-Service | ConvertTo-Html -Property Name, Status -Head $style | Foreach-Object { #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 #open the page in Internet Explorer Set-Alias ie "$env:programfiles...