【发布时间】:2016-08-02 04:36:58
【问题描述】:
几乎相同的 HTML 脚本,每个都由 Powershell 脚本生成,并创建一个 .html 输出到本地驱动器。输出是在服务器上进行一些查询之后的结果表。
每个 HTML 输出文件都会按预期打开一个格式,但是,我希望将两个输出文件合并到一个脚本中,该脚本将作为单个 HTML 消息输入电子邮件。请原谅粗略的格式 - 为了简单起见,我已从脚本中删除了样式。
这是脚本 1,在 Powershell 中称为 $Table1:
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
<title>App Report</title>
</head>
<body>
<font face='calibri' color='#003399' size='4'><strong>App Server Report</strong></font>
</td>
</tr>
</table>
<table width='auto'><tbody>
<td width='auto' bgcolor='#d98880'' align='center'>Server</td>
<td width='auto' bgcolor='#a9dfbf'' align='center'>Service</td>
</tr>
<tr>
<td width='auto'>Server1</td>
<td width='auto' align='center'>Running</td>
</tr>
</tr>
这是 Script1 的输出,称为 $Table2:
...这里是脚本 2:
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
<title>Web Report</title>
</head>
<body>
<font face='calibri' color='#003399' size='4'><strong>Web Server Report</strong></font>
</td>
</tr>
</table>
<table width='auto'><tbody>
<td width='auto' bgcolor='#d98880'' align='center'>Server</td>
<td width='auto' bgcolor='#aed6f1'' align='center'>Apache Service</td>
<td width='auto' bgcolor='#aed6f1'' align='center'>WWW Service</td>
<td width='auto' bgcolor='#aed6f1'' align='center'>WAS Service</td>
</tr>
<tr>
<td width='auto'>SERVER2</td>
<td width='auto' align='center'>Running</td>
<td width='auto' align='center'>Running</td>
<td width='auto' align='center'>Running</td>
</tr>
</tr>
这是格式化的输出:
所以现在在我的 PS 脚本中,我将这两个都放入了 HTML 变量中:
$HTMLmessage = @"
$Table1
$Table2
"@
但是 $Table2 的标题嵌套在前一个表的最后一个 td 中。我知道必须有正确的方法来做到这一点 - 我不懂 HTML,但我们将不胜感激。
谢谢
【问题讨论】:
-
谢谢 Danieboy - 我已经在使用这个 cmdlet,但我认为该是我学习 HTML 的时候了,所以我不太适应。
标签: html powershell