0

I am working in a Software Deployment team, and I am working on a script, to automatically display monthly SW updates on a webpage. We have a Software that generates a HTML file consisting of a table with the information regarding the various SW.

The CSS and an excerpt of what the data looks like:

<style type="text/css"> .myTable {border-collapse:collapse; } 
        .myTable td { padding:2px;spacing:1px;border:1px solid #000000;} 
        </style>
<table Class="myTable">
    <tr>
        <td>
            <b>ID</b>
        </td>
        <td>
            <b>Name</b>
        </td>
        <td>
            <b>Vendor</b>
        </td>
        <td>
            <b>Severity</b>
        </td>
        <td>
            <b>Description</b>
        </td>
    </tr>
    <tr>
        <td>15539</td>
        <td>2460049_DEU</td>
        <td>Microsoft</td>
        <td>Service Pack</td>
        <td>Description of Office 2010 SP1</td>
    </tr>
    <tr>
        <td>15558</td>
        <td>2526291_DEU</td>
        <td>Microsoft</td>
        <td>Service Pack</td>
        <td>Description of Office Visio 2007 SP3 and of Office Visio Language Pack 2007 SP3</td>
    </tr>
</table>

The data gets posted to SAP JAM and looks like this:

current state

What I want to do is delete the column ID, and its values so the output will look like this:

desired state

My post is done with powershell and looks like the following

Invoke-WebRequest -Method Post -uri $uripath -Infile $htmlfile -Headers @{'Accept' = 'application/json'; 'Authorization'= 'Bearer TOKEN'; 'Content-Type'= 'text/html;type=blog'; 'Slug'= $description}

Does anybody know how to delete the column in an easy way via powershell and post the file with CSS to the website?

Thank you all in advance!

nEWBOB
  • 55
  • 9
  • Hmm.. I have already answered that, but remember you kept commenting new requirements, while all it took was for you to have a look at what is possible with the `Head` parameter of [ConvertTo-Html](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/convertto-html) – Theo Apr 09 '20 at 13:29
  • @Tomalak, sounds interesting, how would I do this in this case? Am not very familiar with CSS – nEWBOB Apr 09 '20 at 13:31
  • @Theo, thank you, didn't manage to get it done previously, but will try again – nEWBOB Apr 09 '20 at 14:51
  • Does this answer your question? [How to Convert HTML table to CSV file with same structure with powershell](https://stackoverflow.com/questions/25918094/how-to-convert-html-table-to-csv-file-with-same-structure-with-powershell) – iRon Apr 09 '20 at 18:05
  • How are you getting the HTML? Also invoke-webrequest? – shadow2020 Apr 09 '20 at 22:43
  • If you can add this css somehow ` .myTable > td:first-child { display:none; }` – shadow2020 Apr 09 '20 at 22:44
  • @shadow2020, perfect, thank you a lot, will try to add this with powershell! – nEWBOB Apr 13 '20 at 22:30
  • @shadow2020, weird, when I manually add the line to the file, it does not work, on codepen it worked just right – nEWBOB Apr 13 '20 at 22:39
  • Has be be in the head or inline styling. Perhaps you have an older file cached? – shadow2020 Apr 14 '20 at 15:18
  • @shadow2020, sorry for the late reply. So, I edited the HTML file, and when I open the html file with a browser it works just right, not showing the ID column. But when I post this exact file with my Invoke-WebRequest, it shows the complete table including the ID column, as if it just ignored this part. Then I changed the CSS parameters, just to see that SAP Jam ignores the whole CSS and just posts the html content – nEWBOB May 04 '20 at 18:21
  • Does it ignore inline styling? – shadow2020 May 04 '20 at 19:52
  • What to you mean with inline styling? Inline styling like ID works, is that what you mean? – nEWBOB May 04 '20 at 20:36

0 Answers0