adding additional column to an existing html table

Hi Team,

I have 3 tables just created by using Invoke-WebRequest. I want to 2 additional similar columns to all the 3 tables it. Kindly suggest. Following is my code:

$URL = “https://support.sourcefire.com/supplemental/sf-rules-2015-05-12-seu.html
$data = Invoke-WebRequest -Uri $URL
$tables = @($data.ParsedHtml.getElementsByTagName(“TABLE”)).OuterHTML | Out-File C:\test\dd.html

So… $tables is empty, because you sent the data to Out-File.

Assuming you had not done so, $tables would be raw HTML. There’s not really a trick or magic way to manipulate that. It gets down to string manipulation - PowerShell doesn’t have anything that’d make this easier on you. And assuming you want each row to have two new columns… it’s going to be really hard.

If in fact you’re JUST capturing an HTML table, from the opening and closing TABLE tags, you might try casting it as XML. You’d get a document object model, at least, and maybe you could add nodes to that and then save it out as text.