I'm using the code below to generate Index.htm page. The code works great, but the only thing that I don't want inside that Index.htm page is to have the hyperlinks for directories, as they are useless. Index.htm should contain only hyperlinks to the .htm files inside the C:\inetpub\wwwroot. Any suggestions on how to achieve such result?
$basedir = 'C:\inetpub\wwwroot'
$exp = [regex]::Escape($basedir)
$server = 'http://172.16.x.x'
Get-ChildItem $basedir -Force |
select Name, LastWriteTime,
@{n="URL";e={$_.FullName -replace $exp, $server -replace '\\', '/'}} |
ConvertTo-Html -Fragment URL, Name, LastWriteTime `
-PreContent '<html><head><title>Test</title></head><body>' `
-PostContent '</body></html>' |
% { $_ -replace '<th>.*</th>','<th>Files</th>' `
-replace '<td>(.*?)</td><td>(.*?)</td><td>(.*?)</td>',
'<td><a href="$1">$2</a> $3</td>'
} | Set-Content "c:\inetpub\wwwroot\index.htm"