February 2019
Intermediate to advanced
626 pages
15h 51m
English
ConvertTo-Html may be used to build more complex documents by using the Fragment parameter. The Fragment parameter generates an HTML table only (instead of a full document). Tables may be combined to create a larger document:
# Create the body
$body = '<h1>Services</h1>'
$body += Get-Service |
Where-Object Status -eq 'Running' |
ConvertTo-Html -Property Name, DisplayName -Fragment$body += '<h1>Processes</h1>'
$body += Get-Process |
Where-Object WorkingSet -gt 50MB |
ConvertTo-Html -Property Name, Id, WorkingSet-Fragment # Create a document with the merged body
ConvertTo-Html -Body $body -Title Report | Set-Content report.html
Read now
Unlock full access