Reputation: 95
I have a text file with data as below
ServerName1|Status1 ServerName2|Status2 . . . ServerNamen|Statusn
I have to email the above text in table format using PowerShell. SMTP is already configured.
Email is to be in table format of the above.
Upvotes: 1
Views: 1845
Reputation: 174435
As hinted by Ansgar, you can utilize Import-Csv
to read the text file into objects, and then ConvertTo-Html
to produce the table for the email:
$StatusTable = Import-Csv .\status.txt -Delimiter '|' -Header Server,Status | ConvertTo-Html -As Table
Send-MailMessage -Body $StatusTable -BodyAsHtml ...
Upvotes: 2