以下是我的PowerShell脚本。它会生成一个格式良好的HTML表格。我想将一列加粗(Full%列)。我不能为了我的生活想到一个办法。如何在HTML输出中设置粗体字段
我试过在不同的地方插入粗体标签,并尝试过使用替换方式的想法,但由于列中的数字发生了变化,所以我想不出做到这一点的方法。
$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 = get-css
$style += ""
$report = "
$style$command2Format"$report | Out-File $basedir\test.html
Invoke-Expression $basedir\test.html
输出:
2015-04-01
RichT