dpole86
Goto Top

Powershell Array als Tabelle in HTML ausgeben

Guten Morgen Liebe Administratoren

Ich habe folgendes Problem

Ich will das mir mein Powershellskript die Ausgabe in eine HTML Datei gibt aber als Tabelle.

leider Bekomme ich die Ausgabe zwar in einer Tabelle, in einer Spalte, allerdings mittig und in einer Zeile?

also Die Ausgabe sieht so aus: XXXXX XXXXXX XXXXXX XXXXXX XXXXXX XXXXXX XXXXXXX XXXXXX
XXXXXX XXXXXXX XXXXXX XXXXXXXX XXXXXXX XXXXXXX XXXXXXX XXXXXXX XXXXXXX XXXXXX XXXXXXX XXXXXX XXXXXXXX XXXXXXX XXXXXXX XXXXXXX XXXXXXX XXXXXXX

hätte es aber gerne so:

XXXXXX
XXXXXX
XXXXXX
XXXXXX
XXXXXX
XXXXXX
XXXXXX
XXXXXX
XXXXXX

mein Code sieht so aus:

 
$Rsync_Clients | ConvertTo-Html -Fragment
$Rsync_Clients | Format-Table
#$rsync_html_Zeit = $Rsync_Zeit | ConvertTo-Html -Fragment
#$rsync_html_Datum = $Rsync_Datum | ConvertTo-Html -Fragment
Echo test
Echo $Rsync_Clients
#Echo $rsync_html_Zeit
#Echo $rsync_html_Datum
$html = @"  
    <!DOCTYPE HTML>
    <html>
    <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  
<title> Auswertung </title>
</head>
    <body>
    <table width="1000" height="260" border="0" align="center">  
    <tr>
    <td>
    <div align="left">  
    <div align="left"><img src ="C:\Users\admrd\Desktop\test\bat\Logo\apsolut_Firmenlogo_Farbe.jpg"></div>  
    </td>
    </tr>
    </table>
    <table border="1" border-width: ;border-style: solid;border-color: orange;border-collapse: collapse;>  
    <tr><td>$($Rsync_Clients)</td><td></td><td>$($rsync_html_Zeit)</td><td></td><td>$($rsync_html_Datum)</td><td></td></tr>
    </table>
    </html>
"@  
$html | Out-File $Filename

Ich muss dazu noch sagen, dass Rsync_clients ein Array ist.
dies wurde so deklariert:

 
Remove-PSDrive spwodb
cls
$Date = Get-Date -Format "yyMMdd"; 
$Startzeit = Get-Date -Format "HHmmss"; 
$Mailsubject = "Auswertung RoadWarriors " + $Date; 
$Filename = "aps_export_devices_" + $Date + ".html"; 
#$Folder_rsync = "\\apsv254\c$\Program Files (x86)\ICW\"; 
#$Suchfilter_rsync = "*.txt"; 
$Data_spwo = @();
$Data_rsync=@();

#$a = "<style>" 
#$a = $a + "BODY{background-color:peachpuff;}" 
#$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}" 
#$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;}" 
#$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;}" 
#$a = $a + "</style>" 
$csv = Import-CSV "C:\Users\admrd\Desktop\test\bat\test.csv" -Delimiter ","  
$rsync_result=$csv | ?{(get-date $_.Date) -gt (get-date).AddDays(-7)} | sort Client,Date,Time -Descending | group Client | %{$_.Group} 
echo $rsync_result

$Data_rsync += $rsync_result; 

$Rsync_Clients = @();
$Rsync_Zeit = @();
$Rsync_Datum = @();

foreach($row in $Data_rsync)
{
    $Rsync_Clients += $row.Client;
    $Rsync_Zeit += $row.Time;
    $Rsync_Datum += $row.Date;

}

Danke und Grüße

Roman

Edit: hat sich durch <td width="20"> blub </td> gelöst

Content-Key: 223399

Url: https://administrator.de/contentid/223399

Ausgedruckt am: 28.03.2024 um 23:03 Uhr