December 2015
Intermediate to advanced
760 pages
14h 31m
English
In this recipe, we will create an HTML report based on the system's services.
These are the steps required to create an HTML report using PowerShell:
#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 ...Read now
Unlock full access