Steps for creating a bold column in an HTML display

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:

Answer №2

You can easily achieve your desired outcome by following this straightforward example:

$a = @"
<style>
    TD:nth-child(1){font-weight: bold}
</style>
"@

Get-ChildItem c:\temp -Directory | Select Name,lastwritetime | ConvertTo-Html -Head $a | Set-Content c:\temp\file.html 
ii c:\temp\file.html 

Using the nth-child(1) definition, the first data column will display its text in bold. The same effect can be applied to the 7th column.

As mentioned by Tim Ferrill, browser support is required for this feature, which should not pose a significant challenge.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can file input be saved using only JQuery?

I'm currently developing a Chrome Extension which requires the user to upload an audio file on the options.html page. Due to restrictions, I am unable to utilize PHP in writing this extension. Hence, I am seeking advice on how to save the uploaded aud ...

What's the best way to ensure my side navigation floats on top of my full-width slider?

I am currently working on implementing my side navigation to overlay on top of my full-width slider at the beginning of the webpage. However, when I add the slider, the navigation buttons in my side nav become unclickable. I have tried using the z-index ...

Using javascript to display a vertical scroll bar within a dropdown menu

My challenge is to create a drop-down list that displays the first four items with a vertical scrollbar when the user clicks on it. The remaining items should be visible as the user scrolls through the list. You can find a sample fiddle here: http://jsfid ...

The form inputs within the modal are unresponsive to clicks

I recently began using bootstrap modals and had a separate register/login page from the index. I thought incorporating the login/register form into modals would be a good idea. However, inside the modal, all the inputs are not clickable - only accessible v ...

Discover the secret to incorporating concealed text in WordPress with a hidden div through the power of JavaScript

For a while now, I've been trying to implement a functionality where clicking on a text reveals a dropdown menu with more information, similar to a "read more" feature. I have limited experience in Java or jQuery, and I can't figure out if the i ...

Adjust the div's width dynamically based on its content

I've spent a lot of time reading through the questions and answers on this site, but I still can't figure out why my container won't allow horizontal scrolling for my smaller divs. CSS #theLoopTasksLabels { width:90%; height:90px; ...

What is the best way to convert the results of a Get-ADComputer PowerShell query into a JSON format that includes the IP address and a parent object such as

After running the following ps1 script: Import-Module ActiveDirectory Get-ADComputer -Filter "OperatingSystem -Like '*Windows Server*' -and Enabled -eq 'True'" | Select-Object Name, DNSHostName | ConvertTo-Json | Out-File &quo ...

Adding the AJAX response to the specified element's ID

I'm having trouble inserting radio buttons into a <div> on my page using an AJAX response. The code I have looks like this: // AJAX form for updating tests after category selection $('#categories').change(function(){ category_id ...

The horizontal display of images is currently experiencing issues

I am having trouble displaying images horizontally in a row. I am aiming to show 8 images next to each other, but my current grid system setup is not achieving this. The images are currently stacked on top of each other, but I want them to be aligned horiz ...

sending an HTML request to a server from various devices

Hello everyone, I am new to website development and this is my first post here. I am reaching out because I have been having trouble finding information on a specific topic... My inquiry is about browsing the same website from two different devices, such ...

The HTML 5 video is not functioning properly on an iPad, and the layout of the iPad has black areas on the sides

Having some trouble with an HTML 5 project where the video plays on Chrome and Safari PC browsers but not on iPad. The task at hand is to get it working in portrait mode only, with the video playing when tapped/clicked. <!doctype html> <!--[if ...

Animate in Css3 before the object enters the user's view

Currently, I am utilizing CSS3 animate it from Despite following their instructions, the children within the animation activate prior to entering the viewport. Is this a common issue or is there a specific meta tag required? Your assistance is greatly ap ...

MVC doesn't clear the textbox on submit when utilizing Ajax

I'm seeking assistance with a small issue I'm encountering. I am using AjaxBeginForm to submit a question in a text field, and while the question gets posted successfully to the database, it doesn't clear from the field. The reason for utili ...

Manipulating class properties in AngularJS from a controller

I won't dwell on the reason for this (it's required to override some behavior in Angular Material that is causing issues in Safari), but here is what I am attempting to accomplish: HTML: <style> .changeme{ height: 300px; } </st ...

Deactivating the submit button after a single click without compromising the form's functionality

In the past, I have posed this question without receiving a satisfactory solution. On my quiz website, I have four radio buttons for answer options. Upon clicking the submit button, a PHP script determines if the answer is accurate. My goal is to disable t ...

Showing a placeholder image in the absence of any image

I need help with displaying a default image when there is no uploaded image in the CMS. Here is the code I have so far: <li><img alt="" class="img-responsive" src=" <? if($artikel[0]['images'] == '' ...

Step-by-step guide on generating a canvas with a circle inside whenever a button is pressed

I need help with my code that is supposed to add a new canvas with a circle inside every time a button is clicked. The new canvas should be displayed next to the older ones. Here is my current code: I have two default canvases on the page, and I want new ...

Opening Tags in Selenium for HTML

Is it possible for Selenium with XPath to properly work with HTML that is not in the form of XML, and contains open tags like <col> and <input>? I'm curious if anyone can confirm this. I ask because our automation testing team has noticed ...

Turn off scrolling for the body content without removing the scrollbar visibility

Whenever I click a thumbnail, a div overlay box appears on top: .view-overlay { display:none; position:fixed; top:0; left:0; right:0; bottom:0; overflow-y:scroll; background-color:rgba(0,0,0,0.7); z-index:999; } Some browsers with non-f ...

Concealing elements with HTML, CSS, and JavaScript by setting the display

Issue arose when I set my id="Gabel" display to none, resulting in distorted formatting. Any suggestions for correcting this? Desired outcome is to show display id="Gabel" upon clicking the image on the main page. Here are relevant co ...