Here is my PowerShell script that generates a nicely formatted HTML table. I am struggling to figure out how to make just one column (Full %) bold within the table.
I have attempted inserting bold tags in various places and considered using the replace function, but due to the dynamic nature of the numbers in the columns, I am unable to come up with a solution.
$symmid = 1555
$command1 = symfast -sid $symmid list -association -demand
$command2 = symcfg -sid $symmid list -thin -pool -detail -gb
$basedir = "C:\ts\Scripts"
$timestamp = Get-Date -Format ddMMyyyy
$CSSFile = "$basedir\csstemplate.css"
$css = get-content $CSSFile
$command1 > $basedir\archive_vp\archive_$timestamp.txt
$command2 > $basedir\archive_pool\archive_$timestamp.txt
$regex = '(?ms)P O O L S(.+?)\r\n\s*\r\n'
$command2 = $command2 -join "`r`n"
$command2 = [regex]::Matches($command2,$regex) | foreach {$_.groups[1].value}
$command2 = $command2 -split "`r`n" | select -Skip 5
$command2Format = $command2 | % {
$column = $_ -split ' +'
$hash = [ordered]@{
'Pool Name' = $column[0]
'Flags PTECSL' = $column[1]
'Dev Config' = $column[2]
'Total GBs' = $column[3]
'Usable GBs' = $column[4]
'Free GBs' = $column[5]
'Used GBs' = $column[6]
'Full (%)' = $column[7]
'Subs (%)' = $column[8]
'Comp (%)' = $column[9]
'Shared GBs' = $column[10]
}
New-Object -Type PSCustomObject -Property $hash
} | ConvertTo-Html -Head $a
function get-css
{
foreach($line in $css)
{
$style += $line
}
return $style
}
$style = "<style>"
$style = get-css
$style += "</style>"
$report = "<html><head>$style</head><body>$command2Format</body></html>"
$report | Out-File $basedir\test.html
Invoke-Expression $basedir\test.html
Generated Output: