Skip to content

Instantly share code, notes, and snippets.

$services = Get-Service | Select-Object -Property MachineName,Status,Name,DisplayName | Sort-Object -Property Name
$htmlbase = $services | ConvertTo-Html -Fragment | Out-String
$xml = [xml]$htmlbase
$xml.SelectNodes("//tr/td[contains(text(),'Running')]")|ForEach-Object {$_.setattribute('class','running')}
$xml.SelectNodes("//tr/td[contains(text(),'Stopped')]")|ForEach-Object {$_.setattribute('class','stopped')}
$head=@"
<style>
body {font-family:Arial, Helvetica, sans-serif;}
table {border-collapse: collapse;}
table, th, td {border: 1px solid black; padding: 2px;}