问题描述:

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.

网友答案:

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 ...
相关阅读:
Top