Hello, friends ...
Could anyone help me with this problem: the script below fetches all pdf files in a specific folder and put them on a table in a html file using ConvertTo-Html.
$Path = "C:\MyFolder"
[string]$date = Get-Date -format F
$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;background-color:thistle}"$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:palegoldenrod}"$a = $a + "A"$a = $a + "</style>"
$b = "<h1>MyHeader</h1>"
$OriginalTag = "*<tr><td>*</td></tr>*"
get-childitem . -include *.pdf -recurse | Sort-Object Name | Select-Object Name | ConvertTo-Html -as Table -head $a -body $b -precontent "<h3><P align=justify><b>SomeName</b></P></h3>" -PostContent '<hr>' |foreach { if($_ -like $OriginalTag){ $FinalTag = "<tr><td><a href=""" + "$Path" + """>" $_ -replace $OriginalTag, $FinalTag} else{$_}} | Out-File "$Path\MyPage.htm"; ii "$Path\MyPage.htm"
I need to include a tag for this file using <a href="MyFolder\MyFile"></a> for when I click on pdf file name, this file will be opened (pdf and html files will always be in the same folder)