ConvertTo-Html problem...

rated by 0 users
This post has 0 Replies | 1 Follower

Top 500 Contributor
Posts 5
Facioli Posted: 01-23-2012 1:56 PM

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)

 

Page 1 of 1 (1 items) | RSS
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.