У меня проблема с выводом html. Мой код с циклом, который последовательно берет IP-адрес из списка и составляет следующую таблицу. Мне нужны еще таблицы из данных других коммутаторов.
Моя проблема в том, что я не знаю точно, как повторить только таблицу + ее заголовок, а затем написать и выпустить ее в одном HTML-файле.
Это мой HTML-код таблицы, которую я называю переменной.
$Table = @"
<table
width: 912px;
border-collapse: collapse;
border-width: 2px;
border-style: solid;
border-color: grey;
font: 14pt Calibri;
color: black;
margin-bottom: 10px;
text-align: center;>
<h2>Switch 1</h2>
<div class=subtitle>
THIS is table from switch 1
</div>
<tbody>
<tr>
<th
height="18" width="90";
<td>
Adresa IP</span>
</td>
</th>
<th
height="18" width="90";
<td>
Počet portů</span>
</td>
</th>
<th
height="18" width="90";
<td>
Obsazené porty</span>
</td>
</th>
<th
height="18" width="90";
<td>
Volné porty</span>
</td>
</th>
<th
height="18" width="440";
<td>
Neaktivní porty</span>
</td>
</th>
</tr>
<tr>
<td
height="18" width="90";
border-bottom-width: 2px;
border-bottom-style: inset;">
<span
style="color: black;
font-family: Calibri;
font-size: 11pt; ">
$_</span>
</td>
<td
height="18" width="90";
border-bottom-width: 2px;
border-bottom-style: inset;">
<span
style="color:black;
font-family: Calibri;
font-size: 12pt; ">
$PocetPortu</span>
</td>
<td
height="18" width="90";
border-bottom-width: 2px;
border-bottom-style: inset;">
<span
style="color:black;
font-family: Calibri;
font-size: 11pt; ">
$OP
</span>
</td>
<td
height="18" width="90";
border-bottom-width: 2px;
border-bottom-style: inset;">
<span
style="color:black;
font-family: Calibri;
font-size: 11pt; ">
$PP</span>
</td>
<td
height="18" width="440";
border-bottom-width: 2px;
border-bottom-style: inset;">
<span
style="color:black;
font-family: Calibri;
font-size: 11pt; ">
$vypis</span>
</td>
</tbody>
</table>
"@
Только одна, последняя таблица, всегда появляется на странице вывода, и у меня есть HTML-код, захваченный в цикле, где я получаю значения в переменные.
Команда вызывается с помощью:
$html | ConvertTo-Html -Head $Top_Head, $Style -Body $Table -PostContent $Post_text | Out-File C:\test\test.html
Invoke-Expression C:\test\test.html
Спасибо.